I use Grails 2.5.6 and I try to create 2 different appender.
The first appender should log all errors.
The second appender should log all infos.
I created the appenders but its still not working.
(The log files are created correctly)
log4j = {
appenders{
appender new DailyRollingFileAppender(
name: 'errorLog',
threshold: Level.ERROR,
datePattern: "'-'yyyy-mm-dd",
file: "logs/dev/${Metadata.current.'app.name'}##${Metadata.current.'app-version'}-error.log",
layout: pattern(conversionPattern: '%d [%t] %-5p %c{2} %x - %m%n')
)
appender new DailyRollingFileAppender(
name: 'infoLog',
threshold: Level.INFO,
datePattern: "'-'yyyy-mm-dd",
file: "logs/dev/${Metadata.current.'app.name'}##${Metadata.current.'app-version'}.log",
layout: pattern(conversionPattern: '%d [%t] %-5p %c{2} %x - %m%n')
)
}
root{
error 'errorLog'
info 'infoLog'
}
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'
}
Thanks for help.
Not sure if this causes the problem, but I noticed two things in your example:
The file attribute in both appenders is the same
The block for the log levels is missing (see enter link description here)