Reputation: 3564
I am implementing logging to my application, I am trying to add a pattern to my log file appender,
My code is like this:
log4j = {
appenders {
// append new appenders of your own and add log level and packages/files like to add.
rollingFile name: "myAppender",
maxFileSize: 1024,
file: "C:/GrailsWS/BaseGrails/target/basegrails.log"//""basegrails.log" // C:\GrailsWS\BaseGrails\target\basegrails.log
console name: "myAppender",
layout: pattern(conversionPattern: "%c{2} %m%n")
}
I am following Grails Logging page, After adding pattern line, my basegrails.log not getting any log data.
Upvotes: 0
Views: 148
Reputation: 291
You don't want to have appenders of the same name. I believe what you want to do is give your appenders different names and then apply conversion patterns as needed. If you want, you can define a variable with a common pattern. So, something like:
log4j = {
def commonPattern = "%c{2} %m%n"
appenders {
// append new appenders of your own and add log level and packages/files like to add.
rollingFile name: "rollingLog",
maxFileSize: 1024,
file: "C:/GrailsWS/BaseGrails/target/basegrails.log",
layout: pattern(conversionPattern: commonPattern)
console name: "stdout",
layout: pattern(conversionPattern: commonPattern )
}
// then, use your appenders
trace stdout ['grails.app', ...]
debug rollingFile: ['your.package', ...]
}
Upvotes: 1