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 Multiple log files depending on java class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Reply Bookmark "Multiple log files depending on java class" Watch "Multiple log files depending on java class" New topic
Author

Multiple log files depending on java class

M Murthy
Ranch Hand

Joined: Nov 20, 2004
Posts: 33
Hi all,

How do i make a set of java classes in an application write to one log file while all other java classes write to another log file in the same web application. I am using Tomcat 5.0 server.


Sindhu Murthy<br />SCJP 1.4<br />SCBCD
M Murthy
Ranch Hand

Joined: Nov 20, 2004
Posts: 33
Never mind, I found the answer.
For those of you who are still trying to figure this out, below is the solution.

Suppose you want the class com.foo.xyz to write to a log file (logFile1.log) and all other classes in the application to another log file(logFile2.log), then in your log4j.properties files define

log4j.logger.com.foo.xyz=INFO, R1

where R1 is a file appender pointing to say logFile1.log, also define

log4j.rootLogger=DEBUG, R2

Where R2 is another file appender pointing to say logFile2.log
 
 
subject: Multiple log files depending on java class
 
Threads others viewed
Visual Editor Error
Writing Log4J for my appliaction
Changing the log file name and location in RAD6
Log4j problem in Websphere
Writing to a file through Servlet
developer file tools