- This topic has 6 replies, 2 voices, and was last updated 20 years, 9 months ago by vbfischer.
-
AuthorPosts
-
vbfischerMemberIs there any way to redirect Tomcat’s output to a file? The Tomcat Service for Windows XP seems to do it…
Riyad KallaMemberIf you need Tomcat’s output to go to a file I believe running it via the Windows Services menu or from the command line will be your best bet. When you use the MyEclipse application connectors, they redirect console output to your IDE output window (obviously). I do not believe there is a solution to then redirecting the redirected output BACK to a file from the output window, myabe a plugin for Eclipse exists that will do it?
vbfischerMemberI need to rethink my requirements. Redirecting Tomcat’s output to a file is a workaround to something I’m having trouble figuring out… Maybe this isn’t the best forum to ask it, but since I started, I’ll post it here…
The best option is to use a Logging package, such as Log4j, but I’m having difficulty getting it to work.
I’ve got a basic log4j.properties file specified:
# Set root category priority to DEBUG and appenders to Console and ConsoleLog
log4j.rootCategory=DEBUG, ConsoleLog# console log
log4j.appender.ConsoleLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ConsoleLog.DatePattern=’.’yyyy-MM-dd
log4j.appender.ConsoleLog.File=thelog.log
log4j.appender.ConsoleLog.layout=org.apache.log4j.PatternLayout
log4j.appender.ConsoleLog.layout.ConversionPattern=%d %-5p %c{1}.%M – %m%nAt the top of my servlet, I have:
private static Logger logger = Logger.getLogger(MyServlet.class);When Tomcat starts up, It give the message:
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester).
log4j:WARN Please initialize the log4j system properly.All logger messages display on the console… The file is never created.
Again, I know that doesn’t belong on this forum, but maybe someone here can point me in the right direction 🙂
Riyad KallaMemberI’m going to close this topic so other moderators know its closed, but I’ll still try and see if I can help.
When you say “All logger messages display on the console”, my questions are:
1) Is this running using the MyEclipse connectors? If so, what happens when you just run Tomcat from the service menu, does it just go to the stderr or stdout.txt files in the /tomcat/logs dir?
2) In your properties file you setup a Console appender, not a file appender… why are you expecting this to go to a file?
3) See how others use log4j from servlets, maybe start here: http://www.onjava.com/pub/a/onjava/2002/08/07/log4j.html?page=1
vbfischerMemberThanks.
I found the same information in my log4j manual I bought a while back. Worked like a charm. That onjava article is exactly what I did
Riyad KallaMemberIs everything working alright now?
vbfischerMemberYep. Working great, and the way I originally wanted it to (without system.out.println’s stuck everywhere). Nice thing about logging packages, especially log4j, is that they can be turned off unless you need them…
-
AuthorPosts