By default Glassfish does not provide Log4J support and therefore most likely any Log4J statements end up in thin air. In order to make it work the Log4J archive must be made available to Glassfish alongside with a Log4J configuration file either as properties or XML. The instruction steps here are designed not to rely on Glassfish default loading bye making it explicit.
Installation of Log4J
- Create a new directory inside of /lib directory which is called logging for now
- Put log4j.jar inside the newly created directory logging
- Put the Log4J configuration file inside the logging directory as well
- Fire up Glassfish and open the admin web UI inside a browser (for example http://localhost:4848)
- Click on Application Server, then JVM Settings tab and finally the Path Settings tab
- In the System Classpath box enter in the first line fully qualified path to the Log4J archive, hit enter to go to the next line and then add the fully qualified path to the directory that contains the Log4J settings file
- Click on the Save button
- Restart the Glassfish domain
- Check if the Log4J statements are now available
Notes and Adjustments
Because the System Classpath contains fully qualified paths you can have the Log4J archive and the Log4J settings file anywhere you like. You may want to consider the following:
- You can use ${as.install} to reference the Glassfish installation directory so that the installation directory can be relocated
- If you are using multiple installations it is probably best to place the Log4J settings inside the domain directory so that you can adjust it for each domain
- Or you could use a Glassfish property so that at least the output file (if used) is placed inside its own domain
- Log4J console output may be lost so you a file or other type of appender
Have fun - Andreas Schaefer
This page (revision-3) was last changed on
05-Feb-09 08:57 AM, -0800
by Bobby Bissett.
This page was created on
08-Sep-07 21:37 PM, -0700 by Andreas Schaefer.
More info...
| Version |
Date |
Author |
Size |
Changes ... |
|
3
|
05-Feb-09 08:57 AM, -0800
|
Bobby Bissett |
2010 |
to previous
|
|
2
|
15-Oct-07 16:05 PM, -0700
|
GailRisdal |
2009 |
to previous
|
to last
|
|
1
|
08-Sep-07 21:37 PM, -0700
|
Andreas Schaefer |
1957 |
to last
|