File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Log4j Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Log4j Problem" Watch "Log4j Problem" New topic
Author

Log4j Problem

Sumeet Anand
Greenhorn

Joined: Nov 16, 2002
Posts: 16
Hi All,
I am trying this out :
I have built a wrapper class around Log4j.Now I want to log through the methods of these wrapper classes.
I want to log in 2 different log files .
Some msgs need to be logged in 1 file and some in the other.
But the problem is what should I specify in configuration file for Log4j.
I am specifying this:
***********************************************
<appender name="A1" class="org.apache.log4j.FileAppender">
<param name="File" value="D:/bea/user_projects/CheckFreeDomain/applications/CheckFree/logs/SimpleLog.log" />
<param name="Append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-6r %-5p %30.30c %x - %m\n" />
</layout>
</appender>

<category name="checkFree.MyApp">
<priority value="debug" />
<appender-ref ref="A1" />
</category>
<appender name="A2" class="org.apache.log4j.FileAppender">
<param name="File" value="D:/bea/user_projects/CheckFreeDomain/applications/CheckFree/logs/AuditTrail.log" />
<param name="Append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
</layout>
</appender>


<category name="checkFree.MyApp">
<priority value="debug" />
<appender-ref ref="A2" />
</category>
**********************************************
MyApp is the logger class.
But the problem is when I log messages it only writes to one of the log files and depends upon which wrapper class I am calling first.
why is that happening and its not logging in other file.
Can somebody point out where I am going wrong.
Sumeet.
 
 
subject: Log4j Problem
 
Similar Threads
Help? - Reloading log4j.xml config without jboss restart
what is wrong with log4j configration
Log4J problem
RollingFileAppender not happening
log4j printing to console but not to file from eclipse