Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About saving to different log files by using log4j.properties

 
da shan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic