【发布时间】:2019-12-29 03:40:46
【问题描述】:
我使用 websphere 9 应用服务器来部署 war's 和 ear's,并使用 java.util.logging 将日志生成到应用程序中。我尝试使用属性文件来配置 LogManager 的 FileHandler,但 websphere 将所有其他日志写入我的文件。 我不使用 log4j,因为我无法在运行时设置日志级别。
是否可以通过 websphere 上的应用程序使用 java.util.logging 生成不同的文件日志?
This is my properties file Logger.properties
handlers= java.util.logging.FileHandler
#java.util.logging.ConsoleHandler.level = INFO
#java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
# Set the default formatter to be the simple formatter
java.util.logging.FileHandler.formatter =java.util.logging.SimpleFormatter
# Use UTF-8 encoding
java.util.logging.FileHandler.encoding = UTF-8
# Write the log files to some file pattern
java.util.logging.FileHandler.pattern = C:/Users/pmendez/Documents/Log/testLogs.log
# Limit log file size to 5 Kb
java.util.logging.FileHandler.limit = 5000
# Keep 10 log files
java.util.logging.FileHandler.count = 10
#Customize the SimpleFormatter output format
java.util.logging.SimpleFormatter.format = %d [%t] %-5p (%F:%L) - %m%n
【问题讨论】:
-
请在您的问题中包含您的 logging.properties。
-
好的,我包括这个。我位于 Websphere 的共享库中。
标签: java ejb websphere java.util.logging