SpringBoot log in

By default, Spring Boot will be used SLF4J + Logback for logging, and use INFO the output to the console level.
The SLF4J, i.e. the facade of a simple log (Simple Logging Facade for Java), which can be seen as an interface framework does not provide specific implementation, the specific implementation is similar to complete Log4j, Log4j2, Logback etc. Such logging framework. SLF4J make your code independent of any specific logging API, you can make our program more robust, because you will not let the problem to achieve different logs caused to distraction.
If we program a Spring Boot in to use SLF4J, spring-boot-starter because it is already included in the relevant slf4j jar package. We just need to get to by LoggerFactory:
private static final Logger logger = LoggerFactory.getLogger(ResponseAop.class);

By default, Spring Boot the log output to the console, not to the log file. If you want to write the log file other than the console output, you need to set logging.file or logging.path property in application.yml in. But maybe when the properties configure only logging.file take effect!
Production environment will be equipped with a separate log file, if you want to read in application.xml property in the log file to note: logback.xml early loaded application.yml, logback-spring.xml later than application.yml load if configuration requires logback use application.yml attributes, you need to be named logback-spring.xml. And logback using springProperty application.yml values in order to use, such as: <springProperty scope = "context" name = "logPath" source = "log.path" defaultValue = "logs" />

Guess you like

Origin www.cnblogs.com/doit8791/p/11880152.html