RRZE – Projekte & Prozesse (P&P)

Das Blog der RRZE Stabsstelle "Projekte & Prozesse"

Content

Logging von Grails-Applikationen in JBoss

Kurzanleitung:

  • Aus Classloader-Gründen darf die Applikation nicht eine eigene log4j-xxx.jar beinhalten. Diese kann aus dem war-file entfernt werden durch folgenden Eintrag in BuildConfig.groovy:
    [groovy]
    grails.war.resources = { stagingDir ->
    delete(file:”${stagingDir}/WEB-INF/lib/log4j-1.2.16.jar”)
    delete(dir:”${stagingDir}/WEB-INF/classes/org/grails/tomcat”)
    }
    [/groovy]
    (Der Eintrag mit tomcat ist für das Thema hier nicht relevant, entfernt aber unnötige Klassen aus dem war-file.)
  • Die Grails-Log4j-Konfiguration aus Config.groovy wird im JBoss nicht ausgewertet. Daher sind die Einträge in der JBoss-Log4j-Konfiguration ${JBOSS}/server/default/conf/jboss-log4j.xml nachzuziehen.
    Beispiel für Controller:
    [xml]
    <category name=”grails.app.controller.MyController”>
    <priority value=”INFO”/>
    </category>
    [/xml]
    Man beachte auch das “grails.app.controller“-Präfix!
  • Eine weitere Seltsamkeit ist, dass nach einem Undeploy oder Redeploy eines Grails-war-files das Logging des JBoss komplett beendet wird, d.h. absolut nichts mehr in die Logdatei geschrieben wird. Den Grund und eine saubere Lösung dafür habe ich noch nicht gefunden, aber als Workaround ist es möglich, ein touch auf ${JBOSS}/server/default/conf/jboss-log4j.xml auszuführen. Da diese Konfiguration regelmäßig eingelesen wird, erscheinen die Logmeldungen wieder.

Logging of Grails application in JBoss

Brief administration:

  • Because of  Classloader reasons the application can not have an own  log4j-xxx.jar. It can be deleted from the war-file with the following entry in  BuildConfig.groovy:
    [groovy]
    grails.war.resources = { stagingDir ->
    delete(file:”${stagingDir}/WEB-INF/lib/log4j-1.2.16.jar”)
    delete(dir:”${stagingDir}/WEB-INF/classes/org/grails/tomcat”)
    }
    [/groovy]
    (The entry with tomcat is not relevant for this topic, but deletes unnecessary classes from the war-file.)
  • The Grails-Log4j-configuration from Config.groovy is not evaluated in JBoss. Therefore the entries need to be moved in the JBoss-Log4j-onfiguration ${JBOSS}/server/default/conf/jboss-log4j.xml.
    Example for Controller:
    [xml]
    <category name=”grails.app.controller.MyController”>
    <priority value=”INFO”/>
    </category>
    [/xml]
    Keep the “grails.app.controller“-Prefix in mind!
  • Another oddity is that after an undeploy or redeploy of a Grails-war-file the logging of the JBoss will be completely closed,  which means that absolutely nothing is written in the log file. We haven’t found yet the reason and a clean solution for this problem, but as a Workaround it is possible to make a touch to ${JBOSS}/server/default/conf/jboss-log4j.xml. Because this configuration will be importet regularly the logging messages will reoccur.

Leave a comment

Your email address will not be published Required fields are marked *

You can use the following HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>