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.
精彩评论