How does EasyCVS, a video networking cloud platform, configure the SpringBoot framework log library?

As we all know, writing a log in a program is a very important, but also a place that is easily overlooked by developers. Writing a good program log can help us greatly reduce the pressure of later maintenance. When a program error occurs, you can quickly locate the error through the log.

587.png

When our R&D team develops any product, it will record the program log. There are many hidden program errors, which we find out by checking the log. In this article, we take the video networking cloud platform EasyCVS as an example to share with you how we configure logs.

CVS live video.png

EasyCVS configuration log steps

1. First of all, EasyCVS uses the Java SpringBoot framework to build, so you can use the built-in logging library of the SpringBoot framework.

588.png

Log output format
Time and date: accurate to milliseconds
Log level: ERROR, WARN, INFO, DEBUG or TRACE
Process ID
Separator: — Identifies the beginning of the actual log
Thread name: Enclosed in square brackets (console output may be truncated)
Logger name: Usually use the class name of the source code
Log content

2. But the default log configuration cannot meet the needs of our EasyCVS project, so we need to customize the configuration file.

3. SpringBoot officially recommends using the file name with -spring as your log configuration first (such as using logback-spring.xml instead of logback.xml), and the log configuration file named logback-spring.xml, spring boot can Add some spring boot-specific configuration items to it (mentioned below).

589.png

4. Custom configuration file The configuration log is stored in a file, and it can also be configured to print different logs according to the environment in which the project is running. The log printing level of the local development environment is the debug level, which can be used for our better development. Only the info-level log is printed during operation, which reduces the storage of the server.

590.png

5. Configurable log storage time and archive.

591.png

Guess you like

Origin blog.csdn.net/EasyNVS/article/details/106805871