Reputation: 173
I am trying to log the "info and above level" logging from grails.app.controllers and grails.app.services into this appender "appLog". From the documentation and a lot of google search and ofcourse stack overflow. I understood that all i need is my appender and then logger info. But that never works for me, so i added the root block as below and made it route every log to my appender and I also set my additivity to false so that it won't pull any of the inherited logs. My requirement was very simple, but i could not get it working. I am using grails 2.4.1.
Can someone please shed some light on what is going wrong here?
Below is my configuration:
Log4j:main{
appender name: "appLog",
new org.apache.log4j.DailyRollingFileAppender(
threshold: org.apache.log4j.Level.INFO,
datePattern: "'.'yyyy-MM-dd",
file: log4jFileName,
layout: pattern(conversionPattern: '[%d{yyyy-MM-dd hh:mm:ss.SSS}] %p %c{5} %m%n')
)
info additivity: false, appLog: "grails.app.services.xxxService"
root {
debug 'appLog'
additivity = false
}
}
Upvotes: 0
Views: 1131
Reputation: 10689
A couple things I'm seeing wrong here:
name: "appLog"
portion should be inside of the DailyRollingFileAppender
constructor.Try changing the configuration to this:
log4j = {
appenders {
appender new org.apache.log4j.DailyRollingFileAppender(
name: "appLog",
threshold: org.apache.log4j.Level.INFO,
datePattern: "'.'yyyy-MM-dd",
file: log4jFileName,
layout: pattern(conversionPattern: '[%d{yyyy-MM-dd hh:mm:ss.SSS}] %p %c{5} %m%n')
)
}
info additivity: false,
appLog: "grails.app.services.xxxService"
root {
debug 'appLog'
}
}
Upvotes: 1