简体   繁体   中英

grails / gorm / org.hibernate.type at TRACE prints nothing

I can't configure (logging bind variables used in hibernate prepared statements) using log4j.xml, but can using the log4j DSL in Config.groovy. (记录在休眠准备语句中使用的绑定变量),但是可以在Config.groovy中使用log4j DSL。

We need to configure logging for different environments without building different WARs for each and thus need to use log4j.xml rather than the DSL, if possible.

Have put


<logger name="org.hibernate.type">
    <level value="TRACE"/>
    <appender-ref ref="console"/>
</logger>

but the bindings don't print. Previously in the DSL they did.


log4j = {
...

trace 'org.hibernate.type' }

very strange, esp as other hibernate logging is controllable via log4j.xml.

Any thoughts much appreciated.

As an aside, is using the DSL within Config.groovy recommended as best practice for managing configuration accross environments flexibly - a compiled object containing configuration seems surprising - but am new to grails.

you can configure your logging based on the environment in the Config.groovy file

// set per-environment 
environments {
    development {
       log4j = {
          ...
       }
    }
    test {
       log4j = {
          ...
       }
    }
}

I suggest you use separate config files for each server. To have a custom config file in your server's home folder, put something like the following into config.groovy:

grails.config.locations = [ "file:${userHome}/customConfig.groovy" ]

Then, create customConfig.groovy in your web server's home folder (something like vim ~tomcat/customConfig.groovy if you're using Linux & Tomcat) and override any properties you want. The only snag is that for the logging DSL, you need to provide the whole logging block in here (you can't just override selected properties like you can with most other config settings).

This way, you only have to restart your web application when configuration changes and you don't have to have separate builds for different servers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM