【问题标题】:Apache Tomcat Windows stdout/stderr configurationApache Tomcat Windows 标准输出/标准错误配置
【发布时间】:2020-04-12 09:25:45
【问题描述】:

与我之前的许多其他成员一样,我有一些关于在 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=\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) 日志文件的数量和大小,我们将不胜感激!

    谢谢!
    格雷格

    【问题讨论】:

    • 近 2 周没有活动。任何人有任何建议或重定向到可能有助于回答我的问题的其他帖子?谢谢!

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


    【解决方案1】:

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

    看起来要删除文件,您必须创建一个计划任务来执行此操作。

    【讨论】:

    • 我已将这些选项添加到 Windows 中的服务定义中 (tomcatw.exe //ES// -Djava.util.logging.config.file=E:\Apps\Apache Software Foundation\Tomcat 9.0.11\conf\logging.properties -Djava.util.logging.FileHandler.limit = 10240000 -Djava.util.logging.FileHandler.count = 10 -Djava.util.logging.FileHandler.append = false 出现至少要检查 stdout/stderr 文件。如果没有其他人有更好/不同的答案,我会将此问题标记为已回答。
    • 上面的服务定义里的配置不行,有没有其他的办法?
    • @Beschi 打开一个新问题,因为我们需要更多关于not working 含义的背景知识。现有答案中列出了一种替代方法。正如您在答案中看到的那样,Tomcat 服务本身只有几个调整选项,并且无法处理删除 stdout 和 stderr 文件。
    猜你喜欢
    • 2014-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-11
    • 2014-07-22
    • 1970-01-01
    • 2021-09-03
    • 2022-01-19
    相关资源
    最近更新 更多