在maven 项目中是否需要同时具有log4j.properties
和log4j2.xml
才能将日志打印到文件?
还是log4j2.xml
足够?
仅log4j2.xml
就足够了。
或者,仅log4j2.properties
也足够了。
请注意,如果类路径上同时存在log4j2.properties
和log4j2.xml
文件,则log4j2.properties
"获胜"。或者,您可以使用log4j.configurationFile
system 属性显式定义要加载的配置文件。
有关详细信息,请参阅 Log4j2 手册:https://logging.apache.org/log4j/2.x/manual/configuration.html