Wednesday, 6 July 2011

Configure Glassfish with Log4J

In order to configure GlassFish with Log4J, add a to the glassfish server.

1. Copy log4j.jar inside the GlassFish_Home/lib.
2. Put the Log4J configuration file inside GlassFish_Home/lib
3. Fire up GlassFish and open the admin web UI inside a browser (for example http://localhost:4848).
4. Click on 'Server(Admin Server)' -> Click on 'server-config' Configuration -> JVM Settings -> JVM Options.
5. Now Add new property
'-Dlog4j.configuration=file:///${com.sun.aas.instanceRoot}/lib/' based on as you have copied under lib folder in above Step 2. (basically specify the path of file)
6. Click on the Save button and restart glassfish.

Sample content of Log4J properties file (

# enabling Logging for my application

# enabling Logging for the spring framework

log4j.appender.FILE.layout.ConversionPattern=%d{DATE} %-5p %c{1} : %m%n

No comments:

Post a Comment