Grails Logging not working in Forked Mode

不打扰是莪最后的温柔 提交于 2019-12-24 02:15:37

问题


I'm having a problem where logging works correctly when I run tomcat in non-forked mode from grails, but does not work correctly in forked mode.

Here is my Log4j configuration:

Config.groovy:

// log4j configuration
log4j = {

appenders {
    file name:"fileLogger", file: "c:/logs/app-log.log", threshold: Level.DEBUG
}

debug fileLogger: ['com.foo', 'BootStrap']

info  fileLogger: ['org.springframework']

error fileLogger: [
        'org.codehaus.groovy.grails.web.servlet',        // controllers
        'org.codehaus.groovy.grails.web.pages',          // GSP
        'org.codehaus.groovy.grails.web.sitemesh',       // layouts
        'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
        'org.codehaus.groovy.grails.web.mapping',        // URL mapping
        'org.codehaus.groovy.grails.commons',            // core / classloading
        'org.codehaus.groovy.grails.plugins',            // plugins
        'org.codehaus.groovy.grails.orm.hibernate',      // hibernate integration
        'org.hibernate',
        'net.sf.ehcache.hibernate']
}

When I run grails run-app, the log file is correcly populated.

However, when I change my BuildConfig.groovy file to run tomcat in forked mode:

BuildConfig.groovy:

grails.project.fork = [
    run: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256]
]

The log file does not get populated.

Is there something wrong with my configuration? Why would it work in one mode, but not the other?


回答1:


You have the threshold for the appender set to DEBUG level. I think in the forked tomcat mode the default level is set to INFO. In order to make it work for the forked mode you might need to increase the logging level to INFO and change DEBUGs to INFOs.

info fileLogger: ['org.springframework', 'com.foo', 'BootStrap']



来源:https://stackoverflow.com/questions/16696396/grails-logging-not-working-in-forked-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!