In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to save the console log in the SpringBoot project". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this article "how to save the console log in the SpringBoot project" can help you solve the problem.
Save configuration of SpringBoot console Log
Scenario: the console log needs to be saved in the SpringBoot project.
Implementation method:
1. In the configuration file application-prod.yml
The configuration is as follows:
Logging: config: classpath:logback-spring-prod.xml2.logback-spring-prod.xml
This file is recorded in the console to print the log and save the path configuration as follows:
% black (% contextName -)% red (% d {yyyy-MM-dd HH:mm:ss})% green ([% thread])% highlight (%-5level)% boldMagenta (% logger {60}) -% gray (% msg%n) DEBUG ACCEPT DENY ${logPathDebug} / ${name} _ debug.log ${logPathDebug} / ${name} _ debug.log.%d {yyyy-MM-dd}.% i.log ${maxHistory} 50MB% d {yyyy-MM-dd HH:mm:ss.SSS} [% thread]-[%-5level] [% logger {50}:% line ] -% msg%n INFO ACCEPT DENY ${logPathInfo} / ${name} _ info.log ${logPathInfo} / ${name} _ info.log.%d {yyyy-MM-dd}.% i.log ${maxHistory} 50MB % d {yyyy-MM-dd HH:mm:ss.SSS} [% thread]-[%-5level] [% logger {50}:% line] -% msg%n WARN ACCEPT DENY ${logPathWarn} / ${name} _ Warn.log ${logPathWarn} / ${name} _ warn.log.%d {yyyy-MM-dd}.% i.log ${maxHistory} 50MB% d {yyyy-MM-dd HH:mm:ss.SSS} [% thread]-[%-5level] [% logger {50}:% line] -% msg%n ERROR ACCEPT DENY ${logPathError} / ${name} _ error.log ${logPathError} / ${name} _ error.log.%d {yyyy-MM-dd}.% i.log ${maxHistory} 50MB% d {yyyy-MM-dd HH:mm:ss.SSS} [% thread]-[%-5level] [% logger {50}:% line] -% msg%n 0 ${queueSize} 0 ${queueSize} 0 ${queueSize} 0 ${queueSize}
Note:
The path to the Chinese log is stored under / usr/server/shop/logs/.
How does a SpringBoot project save the runtime log of a service
The problem is relatively simple, with only two steps to complete.
Configure the file for the log4j output log
In pom, you need to refer to lombok dependency, and the version can follow your springboot husband version.
Org.projectlombok lombok true StudentContext% d {yyyy-MM-dd HH:mm:ss.SSS}%-5level [% thread]% logger {76}.% M\ (% line\) -% msg%n UTF-8 ${log.path} / student/student.%d {yyyy-MM-dd} .log 60% d {yyyy-MM-dd HH:mm:ss.SSS}%-5level [% thread]% logger {76}.% M\ (% line\ ) -% msg%n UTF-8 ${log.path} / student/student.warn.%d {yyyy-MM-dd} .log 60 % d {yyyy-MM-dd HH:mm:ss.SSS}%-5level [% thread]% logger {76}.% M\ (% line\) -% msg%n UTF-8 WARN ACCEPT DENY ${log.path} / student/student.error.%d {yyyy-MM-dd} .log 60% d {yyyy-MM-dd HH:mm:ss.SSS} %-5level [% thread]% logger {76}.% M\ (% line\) -% msg%n UTF-8 ERROR ACCEPT DENY
Log4j outputs the log file and puts it under resources. Note that the fileNamePattern tag is replaced with something that identifies the role of your microservice, such as the student management system I wrote, so it uses student.
In application specify the location of this configuration file logging: level: com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver: WARN config: classpath:logback-common.xml on "how to save console logs in the SpringBoot project". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.