开发者

Configuring Grails Access Logging from run-app

Since calling run-app uses the tomcat-plugin in grails, how do I modify the grails AccessLogValve in the server.xml开发者_Go百科 when it does not exists?

I only need this for development since in production I will just deploy the war to tomcat.

Thanks In Advance


You can configure it in a callback for the 'ConfigureTomcat' event in scripts/_Events.groovy:

import org.apache.catalina.valves.AccessLogValve

eventConfigureTomcat = { tomcat ->
 tomcat.host.addValve new AccessLogValve(
  directory: basedir, prefix: 'localhost_access_log.', pattern: 'common')
}


I had to wrap this in a dev environment block or I got horrible errors outside of dev

Here's what I ended up with, but I'm still not happy with it, as

grails run-war -https

isn't happy

eventConfigureTomcat = { tomcat ->
    if (grailsEnv == "development") {
        tomcat?.host?.addValve new AccessLogValve(
            directory: basedir,
            prefix: 'localhost_access_log.',
            suffix: '.log',
            pattern: 'common')
    }
}

produces this:

[unzip] Expanding: foo.war into /Users/tak/.grails/1.3.7/projects/foo/war
Running Grails application..
java.lang.NullPointerException: Cannot set property 'hostname' on null object
at org.grails.tomcat.TomcatServer.startSecure(TomcatServer.groovy:273)

sadness.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜