|
package com.company.name.application
class Domain { private static final Logger LOG = Logger.getLogger( Domain.class.getPackage().getName() ) public static List staticMethod() { println( "LOG object is: ${LOG.class.name} | debug enabled? ${LOG.isDebugEnabled()}" ) println( "Domain.class.getPackage().getName() = ${Domain.class.getPackage().getName()}" ) println( "LOG.getLevel() = ${LOG.getLevel()}" ) def result = [] try { result = Domain.executeQuery( HQL, argsList ) LOG.debug( "results returned by HQL: ${results}" ) }catch( Exception e ) { LOG.error( "error caught executing HQL", e ) } return results } in my config.groovy I have this: debug logFile:"com.company.name.application", "grails.app", "org.hibernate.SQL" there is not log4j output and the result of the println statements from the static method is: LOG object is: org.apache.log4j.Logger | debug enabled? false Domain.class.getPackage().getName() = com.company.name.application LOG.getLevel() = null can someone please help me get logging working in a static method of a Domain class. thank you |
|
> class Domain {
> private static final Logger LOG = Logger.getLogger( > Domain.class.getPackage().getName() ) private static final Log LOG = LogFactory.getLog(Domain) You can probably use the Log4J classes directly, but since everything else goes through the Commons Logging API, you should really use that. > in my config.groovy I have this: > > debug logFile:"com.company.name.application", > "grails.app", > "org.hibernate.SQL" Try it without the "logFile:" bit, just to make sure there isn't a problem in that configuration. Cheers, Peter --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
thanks peter,
i removed the 'logfile' bit ( and switched to commons logging ), and i now see the log output in the stdout....but when i go to test and prod, i will need this info in the log file as i don't log to stdout in those environments. you're thinking it is something incorrect with my setup? i attached my DEV setup from config.groovy below thank you for your help environments { development { log4j = { appenders { console name:'stdout', layout:pattern(conversionPattern: '%d{yyyy-MM-dd HH:mm:ss} [%-5p] %m%n') appender new DailyRollingFileAppender( name:"logFile", fileName:"app.log", layout:pattern(conversionPattern: '%d{yyyy-MM-dd HH:mm:ss} [%-5p] %m%n') ) } root { warn( 'stdout', 'logFile' ) additivity = false } debug logFile:"com.company.name.application" } } |
|
> you're thinking it is something incorrect with my setup? i attached my DEV
> setup from config.groovy below You may not have the threshold set appropriately for your appender. Remember, appenders won't log any messages below their threshold. Try: appenders { console name:'stdout', ... appender new DailyRollingFileAppender( name:"logFile", fileName:"app.log", threshold: Level. DEBUG) } Also, if that doesn't work, move the configuration out of the environment-specific block. Peter --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | See how NAML generates this page |
