Search code examples
windowsstdoutstderrjava.util.loggingtomcat9

Apache Tomcat Windows stdout/stderr configuration


Like many other members before me, I have some questions surrounding configuring Apache Tomcat logging on Windows. To be more specific, my questions surround the proper method(s) for limiting the size and number of log files that are created for stderr/stdout of the Apache Tomcat server as a whole.

My Java knowledge is pretty much limited to whatever I've been able to find on the web in searches.

What I believe I understand is this:

  • The Apache Tomcat service on Windows defaults to the -std(out|err).yyyy-mm-dd.log
  • The Apache Tomcat service uses the following options in the Java startup definition:
      -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
      -Djava.util.logging.config.file=<tomcat_home>\conf\logging.properties
  • The Apache Tomcat service defines the majority of its core logging options within the logging.properties file.

  • Is there a proper configuration/directive/option that can/should be added to the logging.properties file to limit the size, number, count, etc. of the std(out|err) log files?

    My main confusion is with how the loggers and handlers are defined within the logging.properties file with respect to the Tomcat service itself.

    If this has been answered in another thread that I didn't find before posting this, please redirect me. I have tried to follow along with Apache's documentation for logging (https://tomcat.apache.org/tomcat-9.0-doc/logging.html) but I don't know if I can simply add options like maxDays, count, and maxCapSize (or whatever the appropriate option and value should be) directly into the <tomcat_home>\conf\logging.properties file or if I have to use a different way?

    Any help or direction that gets me to a better understanding of this and how to accomplish my end goal of limiting the number and size of std(out|err) log files is and will be greatly appreciated!

    Thanks!
    Greg


    Solution

  • According to Apache Tomcat 9 Windows Service How-To There are only the following options:

    --LogPath   %SystemRoot%\System32\LogFiles\Apache   Defines the path for logging.  Creates the directory if necessary.
    --LogPrefix commons-daemon  Defines the service log filename prefix. The log file is created in the LogPath directory with .YEAR-MONTH-DAY.log suffix
    --LogLevel  Info    Defines the logging level and can be either Error, Info, Warn or Debug. (Case insensitive).
    --StdOutput     Redirected stdout filename. If named auto then file is created inside LogPath with the name service-stdout.YEAR-MONTH-DAY.log.
    --StdError      Redirected stderr filename. If named auto then file is created inside LogPath with the name service-stderr.YEAR-MONTH-DAY.log.
    

    Looks like for deleting of files you would have to create a scheduled task to do so.