Question

We are using the Windows installation of Tomcat 6. By default, the log4j output for our app goes to the ${catalina.base}/logs/stdout_.log file. This log file only rolls over when we restart Tomcat, and the file name always includes the date.

I would prefer it to behave like a DailyRollingFileAppender, where it renames the file when it rolls over... that way I can just open Notepad++ and see today's logs, since Notepad++ will remember that I opened that same file yesterday. :)

I know I can just create another appender in log4j, but I would end up with the stdout.log and another log file, and I'm afraid there would be a minor performance hit for logging to both files. I've tried adding swallowOutput=true to my context.xml but I still get all logging in stdout.log. Any ideas?

Was it helpful?

Solution

Have you tried the steps outlined in Logging in Tomcat? If you follow the steps you'll end up with log4j.properties in the lib directory that you can customize to your heart's content.

OTHER TIPS

The biggest performance hit is when preparing objects that you want to log (you know, when you do logger.info(" operating on " + myObject.toString + " bla bla bla" ) then doing myObject.toString() has the biggest cost). If you already have them than loggin to file is not a problem. And log4j is really well balanced and optimized, it uses buffers to write logs, so it do not make too frequent calls to file system.

Just create another appender, you will have a differentation from tomcat logs and your appilcation logs. How many logs do you have? A 1GB a day or more that you are afraid of performance loss? Don't assume anything before testing it. Just set-up, and do some kind of performance test.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top