Reputation: 2518
I have a webapp packaged as a war which I deploy in Jetty (version 6.1.25). The web app makes use of log4j. I would like to be able to configure the webapp logging via a config file which is external to the war (i.e. not burnt in).
I've tried using a custom context WebAppContext with an extra class path property pointing to the log4j.properties file that I want to inject to the webapp classpath, but this did not work.
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="contextPath">/quantel</Set>
<Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/quantel</Set>
<Set name="extraClasspath">quantel/log4j.properties</Set>
</Configure>
I get the following error message:
log4j:WARN No appenders could be found for logger (org.apache.commons.configuration.ConfigurationUtils).
log4j:WARN Please initialize the log4j system properly.
Is it possible to do this with Jetty?
Thanks in advance.
Upvotes: 2
Views: 4535
Reputation: 129
If you just want to set the logging level to debug, add a java option on jvm start-up arguments:
vi ${jetty.base}/start.d/start.ini:
--exec
-Dlog4j.debug
If you want a full control of logging configuration without access of WAR, also add a java option:
--exec
-Dlog4j.configuration=file:resources/log4j.xml
See also:
External log4j property file with Jetty
Upvotes: 0
Reputation: 2518
I've adjusted the xml configuration above to add the folder containing the log4j config file to the webapp classpath, instead of just adding the config file itself. It is now working, but it is not clear to me why.
My working configuration looks like:
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="contextPath">/quantel</Set>
<Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/quantel</Set>
<Set name="extraClasspath"><SystemProperty name="jetty.home" default="."/>/quantel</Set>
</Configure>
Upvotes: 1