473,799 Members | 3,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.log4 j.RollingFileAp pender
#log4j.appender .stdout=org.apa che.log4j.Conso leAppender
log4j.appender. rollinglogfile. layout.Conversi onPattern=%d{dd MMM yyyy
HH\:mm\:ss,SSS} %-5p %-20t %c{3} - %m%n
log4j.appender. rollinglogfile. Threshold=DEBUG
log4j.appender. rollinglogfile. layout=org.apac he.log4j.Patter nLayout
log4j.appender. stdout.layout.C onversionPatter n=%d{dd MMM yyyy
HH\:mm\:ss,SSS} %-5p %-20t %c{3} - %m%n
log4j.debug=fal se
admincentral.ds l.vdr.docsrv=vd r
log4j.appender. stdout.Threshol d=DEBUG
log4j.appender. rollinglogfile. MaxFileSize=10M B
log4j.appender. rollinglogfile. File=D\:\\Apach e Tomcat
4.0\\bin\\Admin Central.log
admincentral.ds l.vdr.port=1542
log4j.appender. stdout.layout=o rg.apache.log4j .PatternLayout
log4j.appender. rollinglogfile. MaxBackupIndex= 5
log4j.rootCateg ory=ERROR, stdout, rollinglogfile
admincentral.ds l.vdr.host=wksa bc
log4j.layout.Co nversionPattern =%d{dd MMM yyyy HH\:mm\:ss,SSS} %-5p
%-20t %c{3} - %m%n"
admincentral.ds l.list=xyz,

b.xml
-----
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configura tion SYSTEM "log4j.dtd" >
<log4j:configur ation xmlns:log4j='ht tp://jakarta.apache. org/log4j/'
debug="false">
<appender name="CONSOLE_A PP"
class="org.apac he.log4j.Consol eAppender">
<layout class="org.apac he.log4j.Patter nLayout">
<param name="Conversio nPattern" value="priority-%-5p;
class - %C; method - %M; message - %m%n"/>
</layout>
</appender>

<appender name="FILE_APP_ DEBUG"
class="org.apac he.log4j.Rollin gFileAppender">
<param name="File" value="debug.lo g" />
<param name="MaxFileSi ze" value="10000KB" />
<param name="MaxBackup Index" value="5" />
<layout class="org.apac he.log4j.Patter nLayout">
<param name="Conversio nPattern" value="%d{MM-dd-yyyy
hh:mm:ss a}; thread-[%t]; priority-%-5p; class - %C; method - %M;
message - %m%n"/>
</layout>
<filter class="org.apac he.log4j.varia. PriorityMatchFi lter">
<param name="PriorityT oMatch" value="DEBUG" />
<param name="AcceptOnM atch" value="true" />
</filter>
</appender>
<appender name="FILE_APP_ INFO"
class="org.apac he.log4j.Rollin gFileAppender">
<param name="File" value="info.log " />
<param name="MaxFileSi ze" value="10000KB" />
<param name="MaxBackup Index" value="5" />
<layout class="org.apac he.log4j.Patter nLayout">
<param name="Conversio nPattern" value="%d{MM-dd-yyyy
hh:mm:ss a}; thread-[%t]; priority-%-5p; class - %C; method - %M;
message - %m%n"/>
</layout>
<filter class="org.apac he.log4j.varia. PriorityMatchFi lter">
<param name="PriorityT oMatch" value="INFO" />
<param name="AcceptOnM atch" value="true" />
</filter>
</appender>
<appender name="FILE_APP_ ERROR"
class="org.apac he.log4j.Rollin gFileAppender">
<param name="File" value="error.lo g" />
<param name="MaxFileSi ze" value="10000KB" />
<param name="MaxBackup Index" value="5" />
<layout class="org.apac he.log4j.Patter nLayout">
<param name="Conversio nPattern" value="%d{MM-dd-yyyy
hh:mm:ss a}; thread-[%t]; priority-%-5p; class - %C; method - %M;
message - %m%n"/>
</layout>
<filter class="org.apac he.log4j.varia. PriorityMatchFi lter">
<param name="PriorityT oMatch" value="ERROR" />
<param name="AcceptOnM atch" value="true" />
</filter>
</appender>
<appender name="CONSOLE_E RR"
class="org.apac he.log4j.Consol eAppender">
<layout class="org.apac he.log4j.Patter nLayout">
<param name="Conversio nPattern" value="Date/Time: %d,
Severity: %-5p, %m%n"/>
</layout>
</appender>
<appender name="FILE_APP_ ERR_EVENT_LOG"
class="org.apac he.log4j.Rollin gFileAppender">
<param name="File" value="erroreve nt.log" />
<param name="MaxFileSi ze" value="10000KB" />
<param name="MaxBackup Index" value="5" />
<layout class="org.apac he.log4j.Patter nLayout">
<param name="Conversio nPattern" value="%d{MM-dd-yyyy hh:mm:ss a};
thread-[%t]; priority-%-5p; class - %C; method - %M; message -
%m%n"/>
</layout>
<filter class="org.apac he.log4j.varia. PriorityMatchFi lter">
<param name="PriorityT oMatch" value="ERROR_EV ENT" />
<param name="AcceptOnM atch" value="true" />
</filter>
</appender>

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

<category name="package name" >
<priority value="ERROR_EV ENT" />
<appender-ref ref="FILE_APP_E RR_EVENT_LOG" />
</category>
<root>
<priority value ="DEBUG" />
</root>

</log4j:configura tion>
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 5606
ra***********@i treya.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.log4 j.RollingFileAp pender
#log4j.appender .stdout=org.apa che.log4j.Conso leAppender
log4j.appender. rollinglogfile. layout.Conversi onPattern=%d{dd MMM yyyy
HH\:mm\:ss,SSS} %-5p %-20t %c{3} - %m%n
log4j.appender. rollinglogfile. Threshold=DEBUG
log4j.appender. rollinglogfile. layout=org.apac he.log4j.Patter nLayout
log4j.appender. stdout.layout.C onversionPatter n=%d{dd MMM yyyy
HH\:mm\:ss,SSS} %-5p %-20t %c{3} - %m%n
log4j.debug=fal se
admincentral.ds l.vdr.docsrv=vd r
log4j.appender. stdout.Threshol d=DEBUG
log4j.appender. rollinglogfile. MaxFileSize=10M B
log4j.appender. rollinglogfile. File=D\:\\Apach e Tomcat
4.0\\bin\\Admin Central.log
admincentral.ds l.vdr.port=1542
log4j.appender. stdout.layout=o rg.apache.log4j .PatternLayout
log4j.appender. rollinglogfile. MaxBackupIndex= 5
log4j.rootCateg ory=ERROR, stdout, rollinglogfile
admincentral.ds l.vdr.host=wksa bc
log4j.layout.Co nversionPattern =%d{dd MMM yyyy HH\:mm\:ss,SSS} %-5p
%-20t %c{3} - %m%n"
admincentral.ds l.list=xyz,

b.xml
-----
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configura tion SYSTEM "log4j.dtd" >
<log4j:configur ation xmlns:log4j='ht tp://jakarta.apache. org/log4j/'
debug="false">
<appender name="CONSOLE_A PP"
class="org.apac he.log4j.Consol eAppender">
<layout class="org.apac he.log4j.Patter nLayout">
<param name="Conversio nPattern" value="priority-%-5p;
class - %C; method - %M; message - %m%n"/>
</layout>
</appender>

<appender name="FILE_APP_ DEBUG"
class="org.apac he.log4j.Rollin gFileAppender">
<param name="File" value="debug.lo g" />
<param name="MaxFileSi ze" value="10000KB" />
<param name="MaxBackup Index" value="5" />
<layout class="org.apac he.log4j.Patter nLayout">
<param name="Conversio nPattern" value="%d{MM-dd-yyyy
hh:mm:ss a}; thread-[%t]; priority-%-5p; class - %C; method - %M;
message - %m%n"/>
</layout>
<filter class="org.apac he.log4j.varia. PriorityMatchFi lter">
<param name="PriorityT oMatch" value="DEBUG" />
<param name="AcceptOnM atch" value="true" />
</filter>
</appender>
<appender name="FILE_APP_ INFO"
class="org.apac he.log4j.Rollin gFileAppender">
<param name="File" value="info.log " />
<param name="MaxFileSi ze" value="10000KB" />
<param name="MaxBackup Index" value="5" />
<layout class="org.apac he.log4j.Patter nLayout">
<param name="Conversio nPattern" value="%d{MM-dd-yyyy
hh:mm:ss a}; thread-[%t]; priority-%-5p; class - %C; method - %M;
message - %m%n"/>
</layout>
<filter class="org.apac he.log4j.varia. PriorityMatchFi lter">
<param name="PriorityT oMatch" value="INFO" />
<param name="AcceptOnM atch" value="true" />
</filter>
</appender>
<appender name="FILE_APP_ ERROR"
class="org.apac he.log4j.Rollin gFileAppender">
<param name="File" value="error.lo g" />
<param name="MaxFileSi ze" value="10000KB" />
<param name="MaxBackup Index" value="5" />
<layout class="org.apac he.log4j.Patter nLayout">
<param name="Conversio nPattern" value="%d{MM-dd-yyyy
hh:mm:ss a}; thread-[%t]; priority-%-5p; class - %C; method - %M;
message - %m%n"/>
</layout>
<filter class="org.apac he.log4j.varia. PriorityMatchFi lter">
<param name="PriorityT oMatch" value="ERROR" />
<param name="AcceptOnM atch" value="true" />
</filter>
</appender>
<appender name="CONSOLE_E RR"
class="org.apac he.log4j.Consol eAppender">
<layout class="org.apac he.log4j.Patter nLayout">
<param name="Conversio nPattern" value="Date/Time: %d,
Severity: %-5p, %m%n"/>
</layout>
</appender>
<appender name="FILE_APP_ ERR_EVENT_LOG"
class="org.apac he.log4j.Rollin gFileAppender">
<param name="File" value="erroreve nt.log" />
<param name="MaxFileSi ze" value="10000KB" />
<param name="MaxBackup Index" value="5" />
<layout class="org.apac he.log4j.Patter nLayout">
<param name="Conversio nPattern" value="%d{MM-dd-yyyy hh:mm:ss a};
thread-[%t]; priority-%-5p; class - %C; method - %M; message -
%m%n"/>
</layout>
<filter class="org.apac he.log4j.varia. PriorityMatchFi lter">
<param name="PriorityT oMatch" value="ERROR_EV ENT" />
<param name="AcceptOnM atch" value="true" />
</filter>
</appender>

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

<category name="package name" >
<priority value="ERROR_EV ENT" />
<appender-ref ref="FILE_APP_E RR_EVENT_LOG" />
</category>
<root>
<priority value ="DEBUG" />
</root>

</log4j:configura tion>
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.propertie s file
used in one of my web apps:
# log4j.propertie s
#---------------------------------------------------------------
# Everything not explicitly stated will output ONLY warn & above (warn,
error, fatal)
#---------------------------------------------------------------
log4j.rootCateg ory=DEBUG, console, roll-error

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

#---------------------------------------------------------------
# Console Appender
#---------------------------------------------------------------
log4j.appender. console=org.apa che.log4j.Conso leAppender
log4j.appender. console.Thresho ld=INFO
log4j.appender. console.layout= org.apache.log4 j.PatternLayout
# Pattern to output the caller's file name and line number.
#log4j.appender .console.layout .ConversionPatt ern=%-4r [%t] %-5p %c %x - %
m%n
log4j.appender. console.layout. ConversionPatte rn=%d{MM/dd/yy HH:mm:ss,SSS}
%-5p %l - (%F:%L) %m%n

#---------------------------------------------------------------
# Rolling File Appender -- for errors
#---------------------------------------------------------------
log4j.appender. roll-error=org.apach e.log4j.Rolling FileAppender
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.MaxFileSi ze=1500KB
log4j.appender. roll-error.MaxBackup Index=2
log4j.appender. roll-error.layout=or g.apache.log4j. PatternLayout
log4j.appender. roll-error.layout.Co nversionPattern =%d{MM/dd/yy
HH:mm:ss,SSS} %-5p %l - %m%n

#---------------------------------------------------------------
# Rolling File Appender - debugging for general
#---------------------------------------------------------------
log4j.appender. roll-debug=org.apach e.log4j.Rolling FileAppender
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.MaxFileSi ze=1000KB
log4j.appender. roll-error.MaxBackup Index=0
log4j.appender. roll-debug.layout=or g.apache.log4j. PatternLayout
log4j.appender. roll-debug.layout.Co nversionPattern =%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
180328
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 put the file "log4j.properties" into this same directory. My log4j.properties file reads:
1
5988
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 is of the tomcat's(System.out.println...) - and because there are 3 tomcats there are 3 logs. The log4j writes to one file only. My question is: How can I tell in the log4j log from which server the request came
4
7426
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 log4j.appender.dbase =org.apache.log4j.jdbc.JDBCAppender log4j.appender.dbase.layout =org.apache.log4j.PatternLayout log4j.appender.dbase.driver =com.microsoft.sqlserver.jdbc.SQLServerDriver log4j.appender.dbase.URL ...
0
1257
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 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern= %d
2
2008
by: Hari2349 | last post by:
Regarding to log4j in java program..Plz help me... -------------------------------------------------------------------------------- Hai, friends i used the log4j.properties file like as below...... log4j.rootLogger=VERBOSE, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppe nder
1
5524
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) <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"...
0
5724
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). It all works, except for one thing -- every warning/error arrives in its own e-mail message... The BufferSize parameters appears intended to regulate this, but no matter
0
1401
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 application. i have place INFO in my code, I can see INFO log in Tomcat console, my log4j.xml file is as below. --------------------------- <?xml version="1.0" encoding="UTF-8"?>
5
4116
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 all client processed by that thread must be logged in corresponding thread specific logger. My problem is that logger merging log content with other logger content, my doubt is Logger.getLogger(...) function return wrong logger object. I am...
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10260
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9078
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.