Logging using Log4j.xml in Glassfish

2019-04-16 17:03发布

问题:

I was using WAS as my application server for deploying ear project.Presently changed to Glassfish. I am using log4j.xml file for logging. Logging is not working in Glassfish.

Is there any dependency in using log4j.xml with glassfish.

Any suggestions/pointers is appreciated

回答1:

If your log4j library is included within your EAR file, then check your app server's JVM properties to ensure the log4j.configuration property is set:

  1. Login to the Glassfish Admin Console (http://[hostname]:4848/)
  2. For your server, navigate to Configuration > JVM Settings > JVM Options
  3. If an entry for -Dlog4j.configuration exists, verify that it contains the location of your log4j.xml file
  4. If an entry do not exist for -Dlog4j.configuration, create one. It must follow the following template: -Dlog4j.configuration=file:///path/to/your/log4j.xml