Log processing - using log4j

Through log4j, the log information is not only printed to the console, but also output to the specified file, according to the configuration information;

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>

1. startup

//自动快速地使用缺省Log4j环境
BasicConfigurator.configure();

//日志记录器
private static Logger LOGGER = LogManager.getLogger(Xx.class);
  • log level:

    LOGGER.info
    LOGGER.warn
    LOGGER.error
    LOGGER.debug

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325946128&siteId=291194637