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 About saving to different log files by using log4j.properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "About saving to different log files by using log4j.properties" Watch "About saving to different log files by using log4j.properties" New topic
Author

About saving to different log files by using log4j.properties

da shan
Greenhorn

Joined: Oct 15, 2004
Posts: 2
Hello,

Basically, I have one Tomcat web server running 3 web apps. I'd like to
log each app to different 3 log files. For example,

App1 to /pkg/logs/app1/App1.log
App2 to /pkg/logs/app2/App2.log
App3 to /pkg/logs/app3/App3.log

I'd tried to setup the log4j.properties file, but failed.

============================================
The log4j.properties file I designed is the following. The problem is that although I seperated the logging tasks, both test1 and test2 logging the same info; that is, I put

test1.info('test1');
test2.info('test2');

"test1" and "test2" are records by both test1.log and test2.log files.

log4j.rootLogger = INFO, test1, test2

log4j.appender.test1=org.apache.log4j.RollingFileAppender
log4j.appender.test1.File=test1.log
log4j.appender.test1.Append=true
log4j.appender.test1.layout=org.apache.log4j.PatternLayout

log4j.appender.test2=org.apache.log4j.RollingFileAppender
log4j.appender.test2.File=test2.log
log4j.appender.test1.Append=true
log4j.appender.test1.layout=org.apache.log4j.PatternLayout

========================

Any helps are appreciated very much,
da Shan
Robert Stuart
Greenhorn

Joined: Jan 09, 2003
Posts: 10
Try adding this above each respective appender

# above the log for app1 - test1 is name of appender
log4j.category.com.App1= DEBUG, test1
log4j.category.com.App2= DEBUG, test2

the idea is to provide the appender with the file structure of the classes each appender is to log.

Hope this helps
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About saving to different log files by using log4j.properties
 
Similar Threads
About log4j.property file
thread safe logging in a servlet
Frontman 2.0 not logging
Log4j - log in different files, same jar , different Main classes
Urgent...Logging for Two different Enterprise applications using Log4j