Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
668 views
in Technique[技术] by (71.8m points)

logging - How to configure logs/catalina.out of tomcat 6 for per-app. (Configure web-app specific log file for sys.out, sys.err)

Requirement is this ...

We have our 3 web-applications deployed in RHEL-5 server, we deployed apps with tomcat 6.0.16. We want to configure stdout, stderr, which are coming in tomcat/logs/catalina.out in app specific log file like,

tomcat/logs/app1.log tomcat/logs/app2.log tomcat/logs/app3.log

we are using log4j, but it is only generating logging details we need stdout per-app which is coming in tomcat/logs/catalina.out

Any Help Appreciated ...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try this,

  1. Each application must use its own log4j. You can achieve this by placing log4j.jar in WEB-INF/lib of each application.
  2. In each log4j's configuration file (default location is WEB-INF/classes), specify the log file name, e.g. log4j.appender.AppLog.File=${catalina.home}/logs/app1.log.
  3. Add swallowOutput="true" for each context so stdout, stderr will go to your own log.

We do this on Tomcat 5.5 but I think it should work on 6.0 also.

EDIT: Here is our META-INF/context.xml,

<?xml version="1.0" encoding="UTF-8"?>
<Context override="true" swallowOutput="true" useNaming="false">
  <WatchedResource>WEB-INF/web.xml</WatchedResource>
  <Manager pathname=""/>
</Context>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...