开发者

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

I can't configure org.hibernate.type (logging bind variables used in hibernate prepared statements) using log4j.xml, but can using the log4j DSL in Config开发者_运维技巧.groovy.

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.


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.


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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜