gradle-tomcat-plugin
gradle-tomcat-plugin copied to clipboard
How to configure tomcat logging level
I'd like to configure tomcat's logging level when using tomcatRunWar, but I don't see any way to do that. Can I drop a logging.properties or log4j.properties file somewhere, or is there another way to set tomcat's logging level?
At the moment you can't. It would have to be exposed. Would you be interested in contributing this feature? If you want to see Tomcat logging you could also run with Gradle -i command line option. That's probably good enough. Is that what you are looking for?
Looking at this again. I actually did put something in place - com.bmuschko.gradle.tomcat.internal.LoggingHandler. At the moment it's just not configurable.
Seconded - this would be huuuuugely helpful for our team. Is there a way around this in the meantime? We are not tomcat experts and are having trouble finding a way around the enormous mass of debug output atm.
edit: Just tried -i - tomcat still gives me all the debug info from my app. Furthermore, info level is still too verbose for our usecase. Really wish we could supply a logging.properties.
In my case I've run gradle providing the following parameter:
gradle tomcatRun -Dlog4j.configurationFile=src/main/resources.log4j.properties
Not optimal but it does the trick for me
We ended up doing something similar (providing a log4j on the classpath of our app).
I tried to use
gradle tomcatRun -Dlog4j.configurationFile=src/main/resources.log4j.properties
but it didn't work I am using tomcat version 7.0.59 is it possible to post the configuration file here ?
We still don't have a better solution for this, do we?
@Koli0842 Nothing happened here in the meantime. Happy to accept pull requests for this.
I managed to workaround this issue by configuring web.xml (works for tomcatRun and tomcatRunWar tasks) for an old (really old) Spring 2.5/Gradle 5.6.2 app:
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>log4jExposeWebAppRoot</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
Seems like a solution has been provided with the last comment.