tags:

views:

490

answers:

1

Hi,

I am little bit confuse about log4j in grails.

I need to log info into info.log, error into error.log and warning into warning.log

if possible, all the files (info,warning and error) should be placed into web-app/ so that i can do check via internet (vpn)

can someone help me to do that ?

+2  A: 

Assuming you are using Grails 1.1+, what about:

appenders {
    file name:'infoLog', file:'info.log', threshold: org.apache.log4j.Level.INFO
    file name:'warnLog', file:'warn.log', threshold: org.apache.log4j.Level.WARN
    file name:'errorLog', file:'error.log', threshold: org.apache.log4j.Level.ERROR
}

root {
    info 'infoLog','warnLog','errorLog'
}

With this configuration, info.log will contain all log messages with level INFO and above (ie. INFO, WARN, ERROR, FATAL), warn.log will contain WARN and above, error.log will contain ERROR and above.

In the example above, I have configured the root logger, so everything (including Grails core) gets logged. But of course, you can configure this more fine-grained if you want.

Hope this helps.

Daniel Rinser
is " file name" type with space ?
nightingale2k1
The code is correct. It defines a FileAppender ("file") with the name 'infoLog' (name: 'infoLog') which writes log message to the 'info.log' file (file: 'info.log'). Have a look at the custom appender section in the docs: http://grails.org/doc/1.1.x/guide/3.%20Configuration.html#3.1.2%20Logging
Daniel Rinser
in my previous configuration I have this appender.logfile = "org.apache.log4j.DailyRollingFileAppender"how to put this on each so that I can have DailyRollingFileAppenderthank you !!
nightingale2k1