2

I am trying to deploy a grails application on JBoss EAP, the problem is that no output from my application is logged except for stdout and stderr. I really don't understand how the logging works in this case since jboss uses some internal logging system and grails uses log4j.

This is my logging configuration in standalone.xml:

    <subsystem xmlns="urn:jboss:domain:logging:1.1">
        <console-handler name="CONSOLE">
            <level name="INFO"/>
            <formatter>
                <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
            </formatter>
        </console-handler>
        <periodic-rotating-file-handler name="FILE">
            <formatter>
                <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
            </formatter>
            <file relative-to="jboss.server.log.dir" path="server.log"/>
            <suffix value=".yyyy-MM-dd"/>
            <append value="true"/>
        </periodic-rotating-file-handler>
        <logger category="com.arjuna">
            <level name="WARN"/>
        </logger>
        <logger category="org.apache.tomcat.util.modeler">
            <level name="WARN"/>
        </logger>
        <logger category="sun.rmi">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb.config">
            <level name="ERROR"/>
        </logger>
        <root-logger>
            <level name="INFO"/>
            <handlers>
                <handler name="CONSOLE"/>
                <handler name="FILE"/>
            </handlers>
        </root-logger>
    </subsystem>

Which is default.

This log4j configuration is in my Config.groovy:

// log4j configuration
log4j = {
    // Example of changing the log pattern for the default console appender:
    //
    //appenders {
    //    console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
    //}

    error  'org.codehaus.groovy.grails.web.servlet',        // controllers
           'org.codehaus.groovy.grails.web.pages',          // GSP
           'org.codehaus.groovy.grails.web.sitemesh',       // layouts
           'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
           'org.codehaus.groovy.grails.web.mapping',        // URL mapping
           'org.codehaus.groovy.grails.commons',            // core / classloading
           'org.codehaus.groovy.grails.plugins',            // plugins
           'org.codehaus.groovy.grails.orm.hibernate',      // hibernate integration
           'org.springframework',
           'org.hibernate',
           'net.sf.ehcache.hibernate'

    all additivity: false, console: [
            'grails.app.controllers.com.redhat.theses',
            'grails.app.domain.your.com.redhat.theses',
            'grails.app.services.com.redhat.theses',
            'grails.app.taglib.com.redhat.theses',
            'grails.app.conf.com.redhat.theses',
            'grails.app.filters.com.redhat.theses'
    ]
}

I really don't understand this logging stuff, it is so confusing, all I want is to log at least all errors, for starters. One would think that such a crucial feature works by default.

If I set this property when starting JBoss:

./standalone.sh -Dorg.jboss.as.logging.per-deployment=false

it works exactly as I want. But is it all right? Why do I have to set this property in order to get such a crucial function as logging, really?

Thank you so much for any help, I am sorry if I sound a bit arrogant, I have been trying to figure this out for hours and I am still where I was at the beginning.

VaclavDedik
  • 1,960
  • 4
  • 20
  • 27
  • JBoss EAP version would certainly help. Also, you may find this answer relevant: http://stackoverflow.com/questions/12670415/log4j-doesnt-log-anything-under-jboss-6-eap. – Szymon Jednac Feb 27 '13 at 14:27
  • JBoss EAP 6.0.0. Sorry for not mentioning it right away. I will look at the question asap, thanks! – VaclavDedik Feb 27 '13 at 18:15

1 Answers1

2

The org.jboss.as.logging.per-deployment environment variable, AKA host property, AKA environment property tells JBoss which logging config to use. Setting it to true tells JBoss to use the logging config in the application being deployed. I would not know how to set that up in Grails Config.groovy. I do the config in JBoss after setting that host property to false. False means use the logging config in JBoss.

In JBoss set the property to false and then just create a grails.app category and have it log to a file Handler. That works for me in Grails and EAP 6.0 running in domain mode.

DAC
  • 707
  • 1
  • 6
  • 20