javatomcatlogfiles

How to write to Tomcat log files


What is the easiest way to print out something in a Tomcat Log file.

I was under the impression that System.out.println() would print to one of the log files.

I just want to print out the value of a string, so the simplest solution would be best. If there is no simple/trivial solution I guess I will use Log4J

EDIT: I used Log4J as follows:

As a class variable I declared:

static Logger log = Logger.getLogger("myClass");

I then placed:

 log.warn("Upload directory: "+destDirectory);

However now I want to read the value of destDirectory, and cannot see it in any of the Tomcat logs?


Solution

  • http://tomcat.apache.org/tomcat-6.0-doc/logging.html

    Seems to explain what your looking for.

    Version Documentation
    Tomcat 11.0 Chapter 22: Logging
    Tomcat 10.1 Chapter 23: Logging
    Tomcat 9.0 Chapter 23: Logging