Skip to main content

GlassFish V3 logging changes

Posted by carlavmott on October 28, 2008 at 2:30 PM PDT

Logging in GlassFish V3 has undergone some changes to leverage the logging utility in JDK. This blogs reviews where we are with the logging mechanism in GlassFish Prelude and since not all of the features are implemented in the Prelude release yet, I'll go over how to make use of the functionality that is there.

The most significant change is that for now we don't have support in the Admin GUI or the command line tool asadmin. That support will be provided in the final release of GlassFish V3. For now, developers using Prelude will have to edit the file found in the domain config directory where you find the domain.xml file. Let's take a look at what can be done.

Developers can update the logger level, change the log filename and set rotation of log files based on file size or a time limit. Some of these changes require a restart of the server and some don't.

First let's talk about setting log levels on loggers. Changes to logger levels are dynamic and don't require a server restart. At the end of the file you will find a list of loggers in GlassFish. I have included the most common loggers so developers can easily find what they want. Below is an excerpt from that file.

#Tools Logger
# EJB Logger

By default all the logger levels are set to INFO because the root level is set to INFO. If the log level is not set on a logger then it inherits the level of its parent going up the chain until it finds a logger with the level set or it reaches the root logger. To set the level on a specific logger you simply uncomment the line in corresponding to the logger and set the level appropriately. Upon saving the file the logging mechanism is notified of a change to the file and resets the log levels for all known loggers based on the information in the file. Note that you can create your own logger, specify the level in the file and it will be updated too.

The log level values are SEVERE, WARNING, INFO, CONFIG, FINE, FINER, and FINEST. Each level includes messages of the level above it so if you set a logger to level INFO you will also get the SEVERE and WARNING messages in addition to the INFO.

One last note about log levels, it is valid to set the level of the loggers at any point in the logger name. For example, say you want all the loggers under javax.enterprise.system.container to print at the FINE level. You simply create a line as follows and save the file.


Once set, the logger level must be explicitly reset to change the level.

Setting file rotation is also done by changing properties in Changing these properties does require a server restart to take affect. There are two ways to set file rotation in Prelude. You can request files be rotated based on a file size or based on a time limit. The properties associated with file rotation are below.

# 0 for no rotation based on time
# rotation limit in bytes, 0 means no rotation, 500000 is the minimum

By default both are set to 0 or no file rotation. If both are set then rotation will be based on time. You can specify the max size of the log file reached to rotate or create the next log file or the max elapsed time reached to rotate the log file.

For now developers will need to edit the file and it should be pretty straight forward. But remember that the team is working on providing tool support for GlassFish V3 final so it will be easier soon.

Related Topics >>


Thanks for an interesting

Thanks for an interesting post. I am wondering and would like to know how does glassfish (I am using version 3.1) load the log level changes dynamically without any restarts. Does it do some kind of polling? If it does then that would be a performance hit, right?

Question - Supporting "novel" logging config for existin wars

Hallo Carla, cheers for this blog posting. I was wondering if you might be able to offer some advice on logging config, since you seem to be really knowledgeable in this area. I'm trying to deploy the latest version of sesame, an RDF triple store on the latest Glassfish v3 build. The trouble is... :) this war deploys fine on tomcat and various other containers, but it uses a particularly gruesome bit of config where it casts the slf4j logger factory to a specific implementation. The war is distributed with a very specific set of jars and in other containers there seems to be no clash. However, when I try and deploy on glassfish the app immediately blows up because it's picking up the container-wide slf4j config and implementation and the deployment thows a class cast exception. I know it's not right that sesame is hard-coded to a specific slf4j logging implementation but I was wondering if you're aware of any glassfish config I might be able to use to shield this particular war from the container-wide implementation? I've asked a question on the sesame list too, since at some point people are going to want to deploy sesame on glassfish v3 :) Cheers in advance for any ideas you might have Best regards, Ian.

Hi ianibbo, I'm looking

Hi ianibbo,

I'm looking into this and am hoping you can give me more info. Which version of GlassFish are you using? Have you tried a recent promoted build? Please feel free to email me.


Carla, Please take a look at Please consider a plugable logging architecture or at least some workaround which would allow me to use slf4j instead of Java logging. Thank you, Gili

Chris, I see that you have filed an issue. Thanks.

jkilgrow, Yes you should be able to register other loggers. Those would be available in addition to the default GlassFish provided loggers.

Hi Chris, I see how that can be very useful. Please file an RFE so I can take a look before the final release of V3.

hi carla, if you need any further information please contact me at christian DOT brennsteiner AT gmail DOT com i think this should be easy to implement. regards chris

more details...

so...i'm guessing that we can also register other loggers here? maybe...the logger in commons logging? i'll have to give that a shot.

hi carla, great news out there. but one question: what i really really really miss in GF is absolute time beased (counting from midnight (12AM)) rotation. OR triggered log file rotation (from outside) e.g. if i want the logfile to be rotated at 12 o clock every day there is no solution to this! and this should really be no problem with an advanced server like gf is. as i understand it rotationTimelimitInMinutes is counting since boot what to me seams not that "usefull" in any case... any comments appreciated. regards chris