I have a simple filter that is outputing a message to a log file. I am following an example from a book. It said I should expect to see the log message in a log file. However I only see the message in the console for Tomcat, not the log file. Any ideas why?
Ok, I see the logs getting output to stdout. But I don't understand what you mean by catalina.out file? Did you mean that Tomcat outputs ServletContext logs to a file called catalina.out? I searched my Tomcat installation for this file and it does not exist. I'm using Tomcat 5.5.
Where would I find official Tomcat documentation of how it handles ServletContext.log? I already search the documentation for Tomcat 5.5 and found no mention. (Just wondering how I would have figured out myself how Tomcat handles these logs).
I'd seriously consider migrating to Tomcat6 or 7 if at all possible. However, that wouldn't change how the logging works.
If there's official documentation on Tomcat's handling of servercontext logs, I haven't noticed it, although having said that, there is a (cryptic) section of the Tomcat docs that cover replacing the default juli system with alternatives such as log4j. It's almost never worth doing that, however, as that requires you to build a custom Tomcat from source.
The logs/catalina.out destination is set via a shell stdio redirect of the JVM's stdout and stderr in the catalina.sh and catalina.bat files.
Yep, I intend moving to Tomcat 6 or 7 at a later stage. It's just that I'm working through a book at the moment which used Tomcat 5 - so I'm using it to ensure all the examples work smoothly.
I searched all the files in my Tomcat installation for references to "catalina.out". The only place I found a reference was in catalina.sh. There is no reference in catalina.bat.
Since I am running on a Windows machine and there is no reference to "catalina.out" in catalina.bat, I'm guessing that I should not expect to see the logs to ServletContext.log outputted to any file - they will only go to stdout. Does this sound correct?
Is there any way for me to configure Tomcat 5 so that it outputs the logs to ServletContext.log to a log file?
Hmmm. I know that in some cases, the Windows spin of Tomcat can produce a catalina.out, but you're right. It isn't handled in the stock catalina.bat. I don't usually run Tomcat under Windows, so I'm not always up on the finer points.
There are probably 2 reasons why catalina.bat doesn't route the logs. First, because typically, Tomcat is run as a Windows Service. Secondly, because Windows can do odd things when you invoke a command line app. For example, when you run the Tomcat startup.bat by double-clicking on it.
You can always route the console output for Tomcat yourself, however: