Log4j Setting Experience

xiaoxiao2021-03-06  14

Log4j is an excellent log API provided by Apache.org, supports flexible configuration features: 1. Support to output to multiple logging media is the most common thing to output logs to console and specified files, which correspond to ORG.Apache. ConsoleAppender and RollingFileAppender under log4j package, the following configuration examples: log4j.rootLogger = info, stdout, my log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target = System.out log4j.appender.stdout . retog4j.patternLayout log4j.Appender.stdout.Layout.conversionPattern =% D {Absolute}% 5P% c {1}:% L -% M% n log4j.appender.my = org.apache. log4j.RollingFileAppender log4j.appender.my.File = inner.log log4j.appender.my.layout = org.apache.log4j.PatternLayout log4j.appender.my.layout.ConversionPattern =% d {ABSOLUTE}% 5p% c {1 }:% L -% m% n log4j.Appender.my.maxFilesize = 500kb log4j.logger.bank2 = debug 2 The third party library uses log4j with a lot of debugging information. In order to avoid interference to existing application debugging, concentrate on debugging the application system being developed, and you need to block the log information of the third party library. This can be used to adjust the level of log4j.RootLogger, such as setting to info. At the same time, set the Java class that is developing applications to the debug level, such as the debug level of the Java class with the package header Bank2 in the above configuration example to Debug You can see the debug information output by the application system.

转载请注明原文地址:https://www.9cbs.com/read-50111.html

New Post(0)