I would like to log messages from one controller in my grails application at the information level to a specific file. Everything else in the information or at any other level should go to another default log file.
However, I cannot get log4J to populate the usage.log file at all, although it is happily written to the "default" list below.
Can someone tell me why my installation does not work?
My log4j installation looks like this:
log4j = { appenders { console name: 'stdout', layout: pattern(conversionPattern: '%d %-5p %c{1} - %m%n') appender new DailyRollingFileAppender( name: 'default', datePattern: "'.'yyyy-MM-dd", layout: pattern(conversionPattern: '%d %-5p %c{1} - %m%n'), file: 'C:/logs/default.log' ) //daily usage log appender new DailyRollingFileAppender( name: 'usage', datePattern: "'.'yyyy-MM-dd", layout: pattern(conversionPattern: '%d %-5p %c{1} - %m%n'), file: 'C:/logs/usage.log' ) } info usage: "grails.app.controllers.com.example.MyController", additivity: false root { info 'stdout', 'default' additivity = true } info 'grails.app' }
UPDATE
I was able to solve this problem by replacing the class mapping of a specific controller with
info usage: 'usage', additivity: true
and then using
private static final log = LogFactory.getLog("usage")
No other documented or described method works, and ideally I can configure it based on a package or class, but it works.
user1740752
source share