Spring Boot log4j2 configuration example
2020-12-13 05:35
标签:default app name public ack ogg you target reporting spring boot 默认log用的是 LogBack。 1. Log4j2 Maven Dependency pom.xml 2. Add log4j2.xml file in resources folder 如果存在log4j2 jar包,springboot会自动配置它。把 3. Spring boot log4j2 demo Application.java Read More: Log4j2 properties file example Spring Boot log4j2 configuration example 标签:default app name public ack ogg you target reporting 原文地址:https://www.cnblogs.com/chenqr/p/11143572.htmllog4j2.xml
放在 src/main/resources
文件夹。package com.howtodoinjava.app;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
private static final Logger LOGGER = LogManager.getLogger(Application.class);
public static void main(String[] args)
{
ApplicationContext ctx = SpringApplication.run(Application.class, args);
LOGGER.info("Info level log message");
LOGGER.debug("Debug level log message");
LOGGER.error("Error level log message");
}
}
文章标题:Spring Boot log4j2 configuration example
文章链接:http://soscw.com/essay/31258.html