Setting up Grails access registration from run-app

Since the run-app call uses the tomcat plugin in grails, how do I change the grails AccessLogValve in server.xml when it does not exist?

I only need this for development, since in production I just breed a war with tomcat.

Thanks in advance

+4
source share
2 answers

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

import org.apache.catalina.valves.AccessLogValve eventConfigureTomcat = { tomcat -> tomcat.host.addValve new AccessLogValve( directory: basedir, prefix: 'localhost_access_log.', pattern: 'common') } 
+5
source

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

This is what I ended up with, but I'm still not happy with it, since

 grails run-war -https 

I do not like

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

produces the following:

 [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
source

Source: https://habr.com/ru/post/1299181/


All Articles