Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logs from different web apps go to same file with log4j?!

Status
Not open for further replies.

gcholakov

Programmer
May 18, 2010
4
BG
Hi, The problem is the following - I have several web apps, running in Tomcat 6. I've noticed that all logs go to one file, which is specific for only one of the web applications! Each file in each application is named unique. What I did wrong?

Here is the log4j.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true" xmlns:log4j=" <appender name="ROLLING_FILE_DEBUG" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="/logs/ssoapps_debug.log" />
<param name="MaxFileSize" value="2MB" />
<param name="MaxBackupIndex" value="10" />
<param name="Threshold" value="DEBUG" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd-MM-yyyy HH:mm:ss} %-5p %c{1} - %m%n" />
</layout>
</appender>
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />
</layout>
</appender>
<logger name="com.sbc" additivity="false">
<priority value="debug" />
<appender-ref ref="ROLLING_FILE_DEBUG" />
</logger>
<logger name="org.apache.log4j.xml" additivity="false">
<priority value="OFF" />
<appender-ref ref="STDOUT" />
</logger>
<root>
<priority value="info" />
<appender-ref ref="STDOUT" />
</root>
</log4j:configuration>
 
I don't understand the question. You're settting the same file for all of them?

Cheers,
Dian
 
No, each application has its own file, but in this strange situation all logs go to one file, which is property of only one application.
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true" xmlns:log4j="
<appender name="ROLLING_FILE_DEBUG_PP" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="/logs/paymentportal_debug.log" />
<param name="MaxFileSize" value="2MB" />
<param name="MaxBackupIndex" value="10" />
<param name="Threshold" value="DEBUG" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd-MM-yyyy HH:mm:ss} %-5p %c{1} - %m%n" />
</layout>
</appender>

<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />
</layout>
</appender>

<logger name="com.sbc" additivity="false">
<priority value="debug" />
<appender-ref ref="ROLLING_FILE_DEBUG_PP"/>
</logger>

<logger name="org.apache.log4j.xml" additivity="false">
<priority value="OFF" />
<appender-ref ref="STDOUT" />
</logger>

<root>
<priority value="info" />
<appender-ref ref="STDOUT" />
</root>
</log4j:configuration>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top