tomcat – Strange behavior of log4j:<context-param> interferes with log4j

Question:

Tomcat has two applications: apps and zaz . The Tomcat \ lib folder contains the log4j.properties file, which is common for both applications. For the first application, the path for outputting logs is configured as follows (in the log4j.properties file):

log4j.appender.apps.File=/usr/local/tomcat/logs/apps/apps.log

and for the second it is similar:

log4j.appender.zaz.File=/usr/local/tomcat/logs/zaz/zaz.log

And what is the oddity in the apps folder, there is a file apps \ Web-inf \ classes \ com \ comp \ cust.properties, and in the file apps \ Web-inf \ web.xml has the following lines:

<context-param>
    <param-name>propsFile</param-name>
    <param-value>com\comp\cust.properties</param-value> 
</context-param>

Moreover, if these lines are commented out, then logs are written to the /usr/local/tomcat/logs/zaz/zaz.log file, and if not commented out, then this file is created, but the logs are not written to it. And this even happens when the cust.properties file is completely empty!

UPD

Moreover, if you transfer the entire contents of the log4j.properties file to the cust.properties file, the logs are written to the /usr/local/tomcat/logs/zaz/zaz.log file.

How does this setting ( propsFile ) affect how propsFile works?

Answer:

Try to remove $ CATALINA_BASE / conf / logging.properties to prevent java.util.logging from generating zero-sized logs. This step is one of the recommendations in the Using Log4j chapter of the Tomcat manual (ref)

In general, Java has a big problem with spawning loggers (ref) , so there may be conflicts in your applications and Tomcat settings.

As another option, make sure that there is space on the disk at the time of logging.

Scroll to Top