Configure log4j log in SpringBoot

Configure log4j log in SpringBoot

All our sql is invisible now, we want to know how it is executed, so we have to look at the log!

1. Import dependencies

The import dependency is as follows:

Insert picture description here

If you do not perform the operation of excluding the logging package, the following error will be reported when starting:

Insert picture description here

2. Write log4j.properties file

Write the log4j.properties file in the resources static directory, as shown below:

Insert picture description here

3. Configure log4j logs in the application.yaml configuration file

In the configuration file, you need to tell the program what kind of log you are using, as shown below:

Insert picture description here

4. Test results

Insert picture description here

5. Expansion

If you do not use log4j logs but use logging logs, as shown below:

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45950109/article/details/112501628