Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to manage logs in springboot

Shulou Source: shulou.com Published: 2022-06-02 10:44:01 11月12日 Update

Springboot how to manage the log, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

SpringBoot add log management

one.

Recently, my own project wants a log recording function, and springboot itself has a built-in log function. However, if you want to input the desired log and output it to disk, and then archive it on a daily basis, or split up the log, etc., the self-contained log only has a simple function. Baidu has summarized it as follows, which is suitable for most application scenarios.

two.

Springboot's pom file will quote a parent.

Org.springframework.boot spring-boot-starter-parent 2.0.0.RELEASE

If you click on this parent, you will have a dependency.

Org.springframework.boot spring-boot-dependencies 2.0.0.RELEASE.. /.. / spring-boot-dependencies

Click on version 2.0, which gives you various integrated package dependencies and specifies the version number, one of which is as follows

Org.springframework.boot spring-boot-starter 2.0.0.RELEASE

Click in again.

Org.springframework.boot spring-boot-starter-logging 2.0.0.RELEASE compile

Click again, AHA, come out, these are the original log packages, so you don't have to rely on them any more, just use ok. The usage is as follows:

Ch.qos.logback logback-classic 1.2.3 compile org.apache.logging.log4j log4j-to-slf4j 2.10.0 compile org.slf4j jul-to-slf4j 1.7.25 compile rsion= "1.0" > which says, color log this thing, you have to download plug-ins, oh, how to? I don't know, , and then configure logging.config=classpath:log/logback-spring.xmllogging.path=D:/nmyslog/nmys logs in yml or properties in the same way as usual, except that this configuration is not only output on the console but also retained on disk, and info/debug/error/warn logs are distinguished, and is it helpful for you to read the above contents after archiving every day? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Log function configuration management version disk help output normal clear content just scene for this that is color console plug-ins files articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Microsoft vpn Docker MySQL