Apache Tomcat Windows stdout / stderr配置

时间:2019-12-19 19:00:18

标签: windows stdout stderr java.util.logging tomcat9

像我之前的许多其他成员一样,我对在Windows上配置Apache Tomcat日志有一些疑问。更具体地说,我的问题围绕适当的方法来限制为整个Apache Tomcat服务器的stderr / stdout创建的日志文件的大小和数量。

我的Java知识几乎仅限于我在搜索中可以在网上找到的一切。

我相信我的理解是:

  • Windows上的Apache Tomcat服务默认为-std(out | err).yyyy-mm-dd.log
  • Apache Tomcat服务在Java启动定义中使用以下选项:
      -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
      -Djava.util.logging.config.file=<tomcat_home>\conf\logging.properties
  • Apache Tomcat服务在logging.properties文件中定义了其大多数核心日志记录选项。

  • 是否可以/应该将适当的配置/指令/选项添加到logging.properties文件中,以限制std(out | err)日志文件的大小,数量,计数等?

    我的主要困惑是,如何在logging.properties文件中相对于Tomcat服务本身定义记录器和处理程序。

    如果在发布此帖子之前,我在另一个未找到的帖子中对此进行了回答,请重定向我。我尝试遵循Apache的日志记录文档(https://tomcat.apache.org/tomcat-9.0-doc/logging.html),但是我不知道是否可以简单地添加诸如maxDayscountmaxCapSize之类的选项(或任何适当的选项和值)直接放入 \ conf \ logging.properties文件中,或者是否必须使用其他方式?

    任何能帮助我更好地理解这一点以及如何实现限制std(out | err)日志文件的数量和大小的最终目标的帮助或指导,都将受到极大的赞赏!
    < / p>

    谢谢!
    格雷格

    1 个答案:

    答案 0 :(得分:0)

    根据Apache Tomcat 9 Windows Service How-To,只有以下选项:

    --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.
    

    看起来要删除文件,您需要创建一个计划任务来实现。