Alex Rivera | Logout

Inject log object in Grails class outside of grails-app

Asked 2009-09-11T12:01:16.493
19

I have a class in src/groovy in my grails project.

How do i make a log field that gets injected with the correct logger for that class ?

Is there a commons logging or just log4j in grails ?

Edit
Report

2 Answers

11

You'd add it just like a regular Java class:

Logger log = Logger.getLogger(getClass()) // log4j

or

Log log = LogFactory.getLog(getClass()) // commons logging
answered 2009-09-11T14:03:42.287
0

Using the standard Log4j's new Logger(getClass()) worked, but logged 'java.lang.Class' for me (using Grails 1.2.1). This problem went away with the Sublog plugin and @WithLog. See http://www.grails.org/plugin/sublog. This plugin also does not make Trace become Debug and Fatal Error...!

answered 2010-04-14T03:02:50.457

Your Answer