I am just working with Glassfish 3.2 and wanted to integrate log4j logging, so I can see Logger outputs in my normal server.log

  • First I downloaded a log4j jar.
  • Then I copied this jar file into my Glassfish /lib directory.
  • Then I created a log4j.properties file and put it into the /config directory of my domain (e.g. GLASSFISH_HOME/domains/domain1/config/)
  • After that I added a JVM option to reference the new properties file (Configurations > server-config > JVM settings > JVM Options > Add JVM option)
    e.g. -Dlog4j.configuration=file:///${com.sun.aas.instanceRoot}/config/log4j.properties
  • Then saving the settings and
  • restarting the Glassfish server
  • Jupp

    Thanks!

  • edib

    does not work for me. why did you make a configuration in logging setting? and configuration file options does not exist here. what should be in it?

  • Daniel Thapa

    how to created a log4j.properties as i dont see any properties file inside the log4j jar