We used log4j in a standalone GlassFish server based on recommendations in this FAQ - see FaqCongifureLog4J. However, this did not work in a cluster environment, until we realized how to configure it properly. The following is the summary of our findings.

Log4j JAR should be added to all $
Unknown macro: {com.sun.aas.instanceRoot}

/lib folders in all node instances.

  • We also added it to the $
/lib folder of the main domain server, although I'm not sure it's actually needed.

  • After adding log4j JAR the whole domain needs to be restarted.

log4j.properties should be added to some folder in all node instances.

  • We used $
    Unknown macro: {com.sun.aas.instanceRoot}

    /lib/classes.

    • We also added it to the $

    /lib/classes folder of the main domain server, although I'm not sure it's actually needed.

The following 2 lines should be added to the System Classpath in your cluster-config->JVM Settings->JVM Classpath Settings:

  • $
    Unknown macro: {com.sun.aas.instanceRoot}

    /lib/log4j.jar

    • $

    /lib/classes (if you put log4j.properties there).

The cluster needs to be restarted to activate log4j settings.

Note: if you need to modify your log4j.properties, the cluster (or just the node instance needs to be restarted to activate new settings).

Thanks,

– Lev