Tomcat 将所有内容记录到 stdout

Tomcat 将所有内容记录到 stdout

我已将 Tomcat 6 安装为 Windows 服务。我的 Web 应用程序的所有日志消息梦熊(使用 记录getServletContext().log())将进入 stdout 日志,而不是我指定的日志文件。这种情况在我添加 dreambear 记录器之前就发生了,当时消息应该仍然进入 localhost 日志而不是 stdout。

以下是日志记录.属性。指定的日志文件已创建,尽管是空的,因此该文件中可能没有语法错误或类似的东西。

handlers = \
    1catalina.org.apache.juli.FileHandler, \
    2localhost.org.apache.juli.FileHandler, \
    3manager.org.apache.juli.FileHandler, \
    4host-manager.org.apache.juli.FileHandler, \
    5dreambear.org.apache.juli.FileHandler, \
    java.util.logging.ConsoleHandler

.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.

2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.

3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager.

4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.

5dreambear.org.apache.juli.FileHandler.level = FINE
5dreambear.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
5dreambear.org.apache.juli.FileHandler.prefix = dreambear.

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter


############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/dreambear].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/dreambear].handlers = 5dreambear.org.apache.juli.FileHandler

或者我应该只使用 Log4J?

答案1

这是dreambearWeb 应用程序的名称吗?还是 servlet?

在这两行中,

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/dreambear].level = INFO 
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/dreambear].handlers = 5dreambear.org.apache.juli.FileHandler

必须Web 应用程序的名称[/梦想熊]而不是 servlet 的日志记录。这样您的日志记录就可以正常工作了。

也可以尝试将日志记录级别更改为全部

5dreambear.org.apache.juli.FileHandler.level = ALL 

相关内容