tags:

views:

48

answers:

1

Hi everyone,

Using a standard log4j configuration for my grails app, with a custom conversion pattern like that :

log4j = {
 appenders {
        console name:'stdout', layout:pattern(conversionPattern: '[%-7p][%d{dd/MM/yyyy HH:mm:ss,SSS}] %C %m%n')
    }

root {
 warn 'stdout'
 additivity = true
}

error  'org.grails.plugins.springsecurity'

error  'org.codehaus.groovy.grails.web.servlet'  //  controllers
// ...

warn   'org.mortbay.log',
 'org.apache.tomcat',
 'org.apache.tomcat.util.digester'

 debug  'grails.app'

}

My grails app start as expected .. with the good conversionPattern ... but only during few log lines ... to finally fallback to the default grails conversionPattern ... :-/

Any idea ?

A: 

I don't code in Grails but I do know log4j very well.

On the surface, it seems you need to inspect those lines that aren't formatted as expected. Chances are, they are not caught by the logger that uses your stdout appender.

From what I can piece together, it looks to me like maybe your warning logger is the only one that uses your stdout appender. Meaning anything other than warnings would not format as expected. Further, it's also possible that loggers present in your libraries catch some log statements but not others.


Basically, the best way to solve this is to modify your pattern to give you good information on your loggers (I would suggest replacing the %C pattern, which is very slow to execute, with %c to see the exact category that was used by the logger). Then, look at the differences between what's properly formatted and everything else.

  • Do they have a common level (info, debug, error, etc)?
  • Do they stem from the same package?
  • Are they 3rd party library calls?

Figure out what they have in common and you will find your error.

gmale