Phate
Phate

Reputation: 6612

Append my application logs to tomcat's ones

Tomcat already has a log displaying information messages like startup ones. I'd like for a servlet of mine to append some custom info to this log.

How to get a tomcat's logger instance from a servlet, so to use it?

Upvotes: 0

Views: 40

Answers (2)

jdiver
jdiver

Reputation: 2348

System.out and System.err messsages by default written to catalina.out log file, BUT most production systems disable System.out logging to a file.

So the best method to log tomcat's own log files from a servlet is to use javax.servlet.ServletContext.log(...) method. Log messages with this method are handled by internal Tomcat logging.

For more information check the Tomcat Servlet Logging API documentation.

Upvotes: 1

Farvardin
Farvardin

Reputation: 5414

when you write to stdo in ypur servlet, the output redirected to tomcat's log file ./logs/catalina.out. so just use this:

System.out.println("Hello");

Upvotes: -1

Related Questions