473,395 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Log4j Issue

Log4j Issue
-----------

Hi,
I am facing a problem related to Log4j...

The problem is such that I have two different Log4j files one in
..properties format and the other in the .xml format..

and their source code is like this

a.properties
--------------

log4j.appender.rollinglogfile=org.apache.log4j.Rol lingFileAppender
#log4j.appender.stdout=org.apache.log4j.ConsoleApp ender
log4j.appender.rollinglogfile.layout.ConversionPat tern=%d{dd MMM yyyy
HH\:mm\:ss,SSS} %-5p %-20t %c{3} - %m%n
log4j.appender.rollinglogfile.Threshold=DEBUG
log4j.appender.rollinglogfile.layout=org.apache.lo g4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ dd MMM yyyy
HH\:mm\:ss,SSS} %-5p %-20t %c{3} - %m%n
log4j.debug=false
admincentral.dsl.vdr.docsrv=vdr
log4j.appender.stdout.Threshold=DEBUG
log4j.appender.rollinglogfile.MaxFileSize=10MB
log4j.appender.rollinglogfile.File=D\:\\Apache Tomcat
4.0\\bin\\AdminCentral.log
admincentral.dsl.vdr.port=1542
log4j.appender.stdout.layout=org.apache.log4j.Patt ernLayout
log4j.appender.rollinglogfile.MaxBackupIndex=5
log4j.rootCategory=ERROR, stdout, rollinglogfile
admincentral.dsl.vdr.host=wksabc
log4j.layout.ConversionPattern=%d{dd MMM yyyy HH\:mm\:ss,SSS} %-5p
%-20t %c{3} - %m%n"
admincentral.dsl.list=xyz,

b.xml
-----
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'
debug="false">
<appender name="CONSOLE_APP"
class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="priority-%-5p;
class - %C; method - %M; message - %m%n"/>
</layout>
</appender>

<appender name="FILE_APP_DEBUG"
class="org.apache.log4j.RollingFileAppender">
<param name="File" value="debug.log" />
<param name="MaxFileSize" value="10000KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{MM-dd-yyyy
hh:mm:ss a}; thread-[%t]; priority-%-5p; class - %C; method - %M;
message - %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.PriorityMatchFilter" >
<param name="PriorityToMatch" value="DEBUG" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<appender name="FILE_APP_INFO"
class="org.apache.log4j.RollingFileAppender">
<param name="File" value="info.log" />
<param name="MaxFileSize" value="10000KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{MM-dd-yyyy
hh:mm:ss a}; thread-[%t]; priority-%-5p; class - %C; method - %M;
message - %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.PriorityMatchFilter" >
<param name="PriorityToMatch" value="INFO" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<appender name="FILE_APP_ERROR"
class="org.apache.log4j.RollingFileAppender">
<param name="File" value="error.log" />
<param name="MaxFileSize" value="10000KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{MM-dd-yyyy
hh:mm:ss a}; thread-[%t]; priority-%-5p; class - %C; method - %M;
message - %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.PriorityMatchFilter" >
<param name="PriorityToMatch" value="ERROR" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<appender name="CONSOLE_ERR"
class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="Date/Time: %d,
Severity: %-5p, %m%n"/>
</layout>
</appender>
<appender name="FILE_APP_ERR_EVENT_LOG"
class="org.apache.log4j.RollingFileAppender">
<param name="File" value="errorevent.log" />
<param name="MaxFileSize" value="10000KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{MM-dd-yyyy hh:mm:ss a};
thread-[%t]; priority-%-5p; class - %C; method - %M; message -
%m%n"/>
</layout>
<filter class="org.apache.log4j.varia.PriorityMatchFilter" >
<param name="PriorityToMatch" value="ERROR_EVENT" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>

<category name="package name">
<priority value="error" />
<appender-ref ref="CONSOLE_APP" />
<!--appender-ref ref="FILE_ERR" /-->
</category>

<category name="package name" >
<priority value="ERROR_EVENT" />
<appender-ref ref="FILE_APP_ERR_EVENT_LOG" />
</category>
<root>
<priority value ="DEBUG" />
</root>

</log4j:configuration>
The problem is that the logs of the a.properties are getting logged on
the Tomcat Server Console when run on the Tomcat Server,, And I have
seperate log files for the a.properties and b.xml, some of the logs of
the a.properties are getting logged on to the b.xml's log files and
some of the b.xml's logs are getting logged on to the a.properties log
file... WHICH should not(I mean to say the logs of a.properties should
get logged into the log files of the a.properties and the logs of the
b.xml should get logged onto the b.xml's log files only)...

I will be waiting for ur replies...

Please its very urgent.

Thanx in Advance...
Jul 17 '05 #1
1 5584
ra***********@itreya.com (Ragavendra BC) wrote:
Log4j Issue
-----------

Hi,
I am facing a problem related to Log4j...

The problem is such that I have two different Log4j files one in
.properties format and the other in the .xml format..

and their source code is like this

a.properties
--------------

log4j.appender.rollinglogfile=org.apache.log4j.Rol lingFileAppender
#log4j.appender.stdout=org.apache.log4j.ConsoleApp ender
log4j.appender.rollinglogfile.layout.ConversionPat tern=%d{dd MMM yyyy
HH\:mm\:ss,SSS} %-5p %-20t %c{3} - %m%n
log4j.appender.rollinglogfile.Threshold=DEBUG
log4j.appender.rollinglogfile.layout=org.apache.lo g4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ dd MMM yyyy
HH\:mm\:ss,SSS} %-5p %-20t %c{3} - %m%n
log4j.debug=false
admincentral.dsl.vdr.docsrv=vdr
log4j.appender.stdout.Threshold=DEBUG
log4j.appender.rollinglogfile.MaxFileSize=10MB
log4j.appender.rollinglogfile.File=D\:\\Apache Tomcat
4.0\\bin\\AdminCentral.log
admincentral.dsl.vdr.port=1542
log4j.appender.stdout.layout=org.apache.log4j.Patt ernLayout
log4j.appender.rollinglogfile.MaxBackupIndex=5
log4j.rootCategory=ERROR, stdout, rollinglogfile
admincentral.dsl.vdr.host=wksabc
log4j.layout.ConversionPattern=%d{dd MMM yyyy HH\:mm\:ss,SSS} %-5p
%-20t %c{3} - %m%n"
admincentral.dsl.list=xyz,

b.xml
-----
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'
debug="false">
<appender name="CONSOLE_APP"
class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="priority-%-5p;
class - %C; method - %M; message - %m%n"/>
</layout>
</appender>

<appender name="FILE_APP_DEBUG"
class="org.apache.log4j.RollingFileAppender">
<param name="File" value="debug.log" />
<param name="MaxFileSize" value="10000KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{MM-dd-yyyy
hh:mm:ss a}; thread-[%t]; priority-%-5p; class - %C; method - %M;
message - %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.PriorityMatchFilter" >
<param name="PriorityToMatch" value="DEBUG" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<appender name="FILE_APP_INFO"
class="org.apache.log4j.RollingFileAppender">
<param name="File" value="info.log" />
<param name="MaxFileSize" value="10000KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{MM-dd-yyyy
hh:mm:ss a}; thread-[%t]; priority-%-5p; class - %C; method - %M;
message - %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.PriorityMatchFilter" >
<param name="PriorityToMatch" value="INFO" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<appender name="FILE_APP_ERROR"
class="org.apache.log4j.RollingFileAppender">
<param name="File" value="error.log" />
<param name="MaxFileSize" value="10000KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{MM-dd-yyyy
hh:mm:ss a}; thread-[%t]; priority-%-5p; class - %C; method - %M;
message - %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.PriorityMatchFilter" >
<param name="PriorityToMatch" value="ERROR" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<appender name="CONSOLE_ERR"
class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="Date/Time: %d,
Severity: %-5p, %m%n"/>
</layout>
</appender>
<appender name="FILE_APP_ERR_EVENT_LOG"
class="org.apache.log4j.RollingFileAppender">
<param name="File" value="errorevent.log" />
<param name="MaxFileSize" value="10000KB" />
<param name="MaxBackupIndex" value="5" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{MM-dd-yyyy hh:mm:ss a};
thread-[%t]; priority-%-5p; class - %C; method - %M; message -
%m%n"/>
</layout>
<filter class="org.apache.log4j.varia.PriorityMatchFilter" >
<param name="PriorityToMatch" value="ERROR_EVENT" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>

<category name="package name">
<priority value="error" />
<appender-ref ref="CONSOLE_APP" />
<!--appender-ref ref="FILE_ERR" /-->
</category>

<category name="package name" >
<priority value="ERROR_EVENT" />
<appender-ref ref="FILE_APP_ERR_EVENT_LOG" />
</category>
<root>
<priority value ="DEBUG" />
</root>

</log4j:configuration>
The problem is that the logs of the a.properties are getting logged on
the Tomcat Server Console when run on the Tomcat Server,, And I have
seperate log files for the a.properties and b.xml, some of the logs of
the a.properties are getting logged on to the b.xml's log files and
some of the b.xml's logs are getting logged on to the a.properties log
file... WHICH should not(I mean to say the logs of a.properties should
get logged into the log files of the a.properties and the logs of the
b.xml should get logged onto the b.xml's log files only)...

I will be waiting for ur replies...

Please its very urgent.

Thanx in Advance...


Whassup?

I haven't seen Log4J used in an XML properties settings before or read
any documentation on it. But here is a sample of a log4j.properties file
used in one of my web apps:
# log4j.properties
#---------------------------------------------------------------
# Everything not explicitly stated will output ONLY warn & above (warn,
error, fatal)
#---------------------------------------------------------------
log4j.rootCategory=DEBUG, console, roll-error

#----------- my web
log4j.category.com.app.portal=DEBUG, roll-debug

#---------------------------------------------------------------
# Console Appender
#---------------------------------------------------------------
log4j.appender.console=org.apache.log4j.ConsoleApp ender
log4j.appender.console.Threshold=INFO
log4j.appender.console.layout=org.apache.log4j.Pat ternLayout
# Pattern to output the caller's file name and line number.
#log4j.appender.console.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %
m%n
log4j.appender.console.layout.ConversionPattern=%d {MM/dd/yy HH:mm:ss,SSS}
%-5p %l - (%F:%L) %m%n

#---------------------------------------------------------------
# Rolling File Appender -- for errors
#---------------------------------------------------------------
log4j.appender.roll-error=org.apache.log4j.RollingFileAppender
log4j.appender.roll-error.File=C:/Tomcat
5.0.19/webapps/Portal/Logs/error.log
log4j.appender.roll-error.Threshold=WARN
log4j.appender.roll-error.MaxFileSize=1500KB
log4j.appender.roll-error.MaxBackupIndex=2
log4j.appender.roll-error.layout=org.apache.log4j.PatternLayout
log4j.appender.roll-error.layout.ConversionPattern=%d{MM/dd/yy
HH:mm:ss,SSS} %-5p %l - %m%n

#---------------------------------------------------------------
# Rolling File Appender - debugging for general
#---------------------------------------------------------------
log4j.appender.roll-debug=org.apache.log4j.RollingFileAppender
log4j.appender.roll-debug.File=C:/Tomcat
5.0.19/webapps/Portal/Logs/debug.log
log4j.appender.roll-debug.Threshold=DEBUG
log4j.appender.roll-debug.MaxFileSize=1000KB
log4j.appender.roll-error.MaxBackupIndex=0
log4j.appender.roll-debug.layout=org.apache.log4j.PatternLayout
log4j.appender.roll-debug.layout.ConversionPattern=%d{MM/dd/yy
HH:mm:ss,SSS} %-5p [%C{1}:%L] %m%n

Please note the following 2 lines that specify where the error and debug
logs are stored, which can be any location or file name that you specify.

log4j.appender.roll-error.File=
log4j.appender.roll-debug.File=

I'm not sure what documentation or who taught you how to use Log4J in the
manner in which you are using it. But hope this helps.

Later
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Aaron Boxer | last post by:
Hello, My application is using a jar file MyJar.jar that uses log4j (I have the latest release of log4j). I have put both MyJar.jar and log4j.jar in a directory in my classpath. I have also...
1
by: Adi | last post by:
Hi, I have a web application (using J2EE) which runs on 3 tomcats (4.0) for Load Balancing. I have recently started to use the Log4j in this application. Currently the logs for this application...
4
rsrinivasan
by: rsrinivasan | last post by:
Hi, I am using log4j to create log message. I want to write the log message to database. So i configured the log4j.properties files like this... # Database Configuration...
0
by: Hari2349 | last post by:
Hai, friends i used the log4j.properties file like as below...... log4j.rootLogger=VERBOSE, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender ...
2
by: Hari2349 | last post by:
Regarding to log4j in java program..Plz help me... -------------------------------------------------------------------------------- Hai, friends i used the log4j.properties file like as...
1
by: Kedar Kachare | last post by:
How to use Log4j to create log files using file appender in a Servlet? Also, how to make that Servlet read the log4j.properties file? I have tried following: My web.xml( I use Eclipse europa)...
0
by: Mikhail Teterin | last post by:
Hello! I'm trying to use log4j's SMTPAppender to get warnings and errors reported by our application via e-mail (in addition to having ALL messages saved into a file via RollingFileAppender). ...
0
by: msg2ajay | last post by:
hello, I have configured %CATALINA_HOME% in Win Environ.But as I configured to "${catalina.home}/MQLog/info/info.log" for "file" in log4j.xml I can't see the log file after running my...
5
by: Abhinay | last post by:
Hi there, I am working on server which used thread pool to process each client request by separate dedicated thread. My intention was each thread ( of thread pool ) have its own logger and hence...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.