Explain the log configuration of spring boot using slf4j + logback
When I was in school, I used java for development. After work, the project team adopted Java Net for development That's it. Www. 18fu. Recently, I began to learn Java and learn some new things. Start looking at springboot and record the problems encountered.
Learning new things is best to start with examples. It's boring to only look at documents, but documents still have to be looked at.
The main purposes of spring boot are:
Slf4j provides a simple and unified interface for various login APIs, so that end users can configure their desired login APIs implementation during deployment. The logging API implementation can choose to directly implement the logging APIs connected to slf4j, such as nlog4j and simplelogger. You can also develop corresponding adapters through the API implementation provided by slf4j, such as log4jloggeradapter and jdk14loggeradapter.
Logback is another open source log component designed by ceki g ü LC ü, founder of log4j. Logback is currently divided into three modules: logback core, logback classic and logback access.
Create a new logback in the SRC file The XML file configuration is as follows:
Package the project, run the project, and generate log files in the set Directory:
If you need to configure logback in other ways, you also need to consult the official documentation.
If the log is not generated after the target directory is configured, the configuration file is not copied to the specified directory. Copy the configuration file to the classes directory under the generated target file (target \ classes).
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.