Tomcat Logging using log4j?
Asked Answered
C

2

2

I have installed Apache tomcat 5.5 as a service in my system. Also i added a custom logging file using log4j for a web application. whenever i used system.out.println("some text") statement in my JSP page by default it goes to the stdout.log file which is in the logs directory of tomcat.i want system.out.println("some text") statement's output to be written in a custom log file rather than the stdout.log file is it possible.

Curtal answered 10/11, 2010 at 8:51 Comment(0)
I
3

When started as a service, you can configure the file locations for the stdout and stderr messages from the Service Manager.

Though I agree with @Brabster, you should be using log4j logging instead of System.out when you want to move into production.

This link has a screenshot and reference. See section "Testing #2"

Irina answered 10/11, 2010 at 9:19 Comment(3)
i can able to change the location of the stdout.log file to my custom log file but the Rolling over is not possible.Also when i stopped and restarted the service the entire file content got vanished.Curtal
@Lalchand: Cant help you there, I dont have Tomcat installed as a service and hence no stdout. Do all other log files in the /logs rotate as expected?Irina
no all the file keeps on growing the file name is like that stdout_20101110.log which means by default tomcat creates a stdout log for a day.Curtal
K
0

Not sure if you can redirect System.out and even if you could it'd be mighty confusing, but why aren't you using the log4j facilities if you've set them up?

i.e. log.info("my message"); instead of System.out.println("my message");?

If you're note sure how to use log4j with Tomcat, there's a tutorial here that should help you get going.

Kemberlykemble answered 10/11, 2010 at 8:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.