Tomcat

Tomcat 正在將所有內容記錄到標準輸出

  • February 4, 2012

我將 Tomcat 6 安裝為 Windows 服務。我的 web 應用程序dreambear中的所有日誌消息(使用 記錄getServletContext().log())都將進入標準輸出日誌,而不是我指定的日誌文件。這甚至在我添加dreambear 記錄器之前就發生了,當時消息應該仍然到達本地主機日誌而不是標準輸出。

以下是logging.properties的內容。指定的日誌文件被創建,雖然是空的,所以這個文件中可能沒有語法錯誤或類似的東西。

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?

dreambearWeb 應用程序的名稱嗎?還是servlet?

在這 2 行中,

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 應用程序的名稱**$$ /dreambear $$**而不是servlet。然後您的日誌記錄將起作用。

也嘗試在此處將日誌記錄級別更改為 ALL

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

引用自:https://serverfault.com/questions/191052