0
votes

I am trying to get my log4j to work with tomcat 7. When i had tomcat 6, it worked fine without any settings in web.xml.

Now, when I have tomcat 7, the custom_log4j.xml appenders aren't working. It logs everything to console logs instead of to my custom log. The custom log is created but it stops logging into it once application layer is started.

I have configured in web.xml an extra parameter because it looked like tomcat 7 needs this param.

<context-param>
    <param-name>log4jFileName<param-name>
    <param-value>src/main/sar/conf/custom_log4j.xml<param-value>
</context-param>

My web.xml is in src/main/webapp/WEB-INF folder.

1

1 Answers

0
votes

Consider this answer as a better approach which can be performed also for Tomcat 8. The steps are:

  • Download the (extra) jar/lib via "JULI log4j jar
  • Create a log4j.properties file. Just get a standard log4j.properties file and customize it to your needs.

Today I did this myself and it works like charm!

You can find more details via this article.

You can also find info via this article.