In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Springboot how to write multiple log files at different levels, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.
Create a logback-spring.xml in the resource directory with the following file content
Logback debug ${CONSOLE_LOG_PATTERN} UTF-8 ${log.path} / ${log.name} _ info.log % d {yyyy-MM-dd HH:mm:ss.SSS} [% thread]%-5level% logger {50} -% msg%n UTF-8 ${log.path} / ${log.name}-info-%d {yyyy-MM-dd}.% i.log 100MB 60 info ACCEPT DENY ${log.path} / ${log.name} _ error.log% d {yyyy-MM-dd HH:mm:ss.SSS} [% thread]%-5level % logger {50} -% msg%n UTF-8 ${log.path} / ${log.name}-error-%d {yyyy-MM-dd}.% i.log 100MB 60 ERROR ACCEPT DENY
Add the following to the yml file in the resource directory
Logging: config: classpath:logback-spring.xml / / location can be specified
Write to the log content
@ Servicepublic class CreateCodeService {private static final Logger logger = LoggerFactory.getLogger (CreateCodeService.class); public CreateCodeDto createCodeFunc (CreateCodeBean createCodeBean) {try {} catch (EncodeBase64Exception e) {logger.error (TimeUtils.getCurrentTime () + "EncodeBase64 exception"); return createCodeDto;} catch (Exception e) {logger.error (TimeUtils.getCurrentTime () + "unknown exception") Return createCodeDto;}
Close the console to print the log
Logging: level: com: error # close the console to print the following log output com to the directory org: springframework: web: errorserver: port: 8083 # cassandra database connection under java. Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.