Spring boot configuration log (easy to understand)

Spring boot log introduction

The dependencies of the jar package in spring boot are as follows; during
actual development, we don’t need to import the log jar package in the maven project. There is a log jar package in the jar package that spring boot starts.
Insert picture description here

SpringBoot uses slf4j logs (I just try this)

Step 1: Create a spring boot project

Step 2: Test the default log level of spring boot in the unit test

To quote the log in this way, the current class
Logger passed in the brackets behind it is the current class Logger logger = LoggerFactory.getLogger(TestHashMapCompare.class);

Write a unit test, write 5 log output levels, from low to high.
Insert picture description here
Look carefully at the log output, the default log level of spring boot is INFO

Step 3: Set the log output level of spring boot

So how do we set the log output level of spring boot? It is very simple
in spring boot. This configuration can be
done in the application.properties file. Com.atguigu is the log output level under the specified package.
Insert picture description hereLook at the console as follows, the configuration is successful
Insert picture description here

Step 4: Configure the log path

Writing this way is to configure it under the current project.
If it is written in the form of D:/*.log, it means outputting to this directory.
Insert picture description here

As shown in the figure below, the log generates the
Insert picture description hereoutput format and other parameters of the log, and there will be time to add it later

Guess you like

Origin blog.csdn.net/qq_38220334/article/details/106415186