我有一个 loggers.config 文件,它指定了一个自定义文件处理程序以将日志消息格式化为文件。除非使用指定的文件模式创建默认文件,否则处理程序将无法工作。然后它会创建一个新文件,并按照模式指定的附加 0 并开始记录到该文件。如何在不先指定默认文件的情况下将其记录到文件中。
这是日志文件:
handlers=com.daniel.logging.MyFileHandler
# Default global logging level.
# This specifies which kinds of events are logged across
# all loggers. For any given facility this global level
# can be overriden by a facility specific level
# Note that the ConsoleHandler also has a separate level
# setting to limit messages printed to the console.
.level= INFO
com.daniel.logging.MyFileHandler.level=INFO
# Naming style for the output file:
com.daniel.logging.MyFileHandler.pattern=daniel%g.log
# Limiting size of output file in bytes -defaulted to 1MB:
com.daniel.logging.MyFileHandler.limit=1MB
# Number of output files to cycle through, by appending an
# integer to the base file name:
com.daniel.logging.MyFileHandler.count=10
# Style of output (Simple or XML):
com.daniel.logging.MyFileHandler.formatter=com.daniel.logging.MyLogFormatter
# Limit the message that are printed on the console to INFO and above.
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
在安装程序中(这是一个应用程序日志记录属性文件,创建了一个文件,其中有一行将 logger.config 文件指定为 logger.properties。几行之后,创建了一个文件并使用命令 CMD [@] >> default_file 2>&1. 我不确定那行是做什么的(我对 bash 很陌生)