Hi, I want to have log output of my packages or classes in a specific appender. But everything is printed out to the root-logger.
Here is my config:
log4j = {
appenders {
console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
file name:'grailslog', file:'grails.log', threshold:org.apache.log4j.Level.DEBUG
file name:'mylog', file:'mylog.log', threshold:org.apache.log4j.Level.DEBUG
}
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'
warn 'org.mortbay.log'
debug 'grails.app'
debug mylog: 'my.package', additivity: true
root {
error 'grailslog'
additivity = true
}
}
I also tried this syntax:
log4j = {
appender.stdout = "org.apache.log4j.ConsoleAppender"
appender.'stdout.layout'="org.apache.log4j.PatternLayout"
appender.'stdout.layout.ConversionPattern'='[%r] %c{2} %m%n'
appender.mylog= "org.apache.log4j.DailyRollingFileAppender"
appender.'mylog.File' = "mylog.log"
appender.'mylog.layout' = "org.apache.log4j.PatternLayout"
appender.'mylog.layout.ConversionPattern' = '%d{[ dd.MM.yy HH:mm:ss.SSS]} [%t] %-5p %c %x - %m%n'
appender.grailslog = "org.apache.log4j.DailyRollingFileAppender"
appender.'grailslog.File' = "grails.log"
appender.'grailslog.layout' = "org.apache.log4j.PatternLayout"
appender.'grailslog.layout.ConversionPattern' = '%d{[ dd.MM.yy HH:mm:ss.SSS]} [%t] %-5p %c %x - %m%n'
rootLogger="error,stdout,grailslog"
logger {
grails="info,stdout,grailslog"
my.package="debug,mylog"
}
}
But this doesn't work any more with the current grails version.