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/02 Report--
This article mainly introduces the example analysis of stepping on the pit and filling the pit based on log4j2.properties. The article is very detailed and has a certain reference value. Interested friends must read it!
Log configuration of log4j2.properties trampling and filling
Facade mode: slf4j
Log library: log4j2
Introduce dependency: compile ('org.springframework.boot:spring-boot-starter-log4j2:2.0.4.RELEASE')
Mining pit
There is a problem with Multiple bindings were found on the class path when starting Application
Potholes: dependency on the default logback is not excluded
Fill in the hole: add to build.gradle:
Configurations {compile.exclude module: 'spring-boot-starter-logging'}
After startup, it is not output according to the configured format
Pothole: the path to the configuration file is not declared in application. [yml | properties]
Fill in: add to application.yml
# specify the location and name of the log4j2 configuration file logging: config: classpath:log4j2.properties format log output parameters
% m outputs the message specified in the code
% p output priority, i.e. DEBUG,INFO,WARN,ERROR,FATAL
% r output the number of milliseconds it took since the application was started to output the log information
% c outputs the category to which it belongs, which is usually the full name of the class
T outputs the name of the thread that generated the log event
% n outputs a carriage return newline character with "rn" for Windows platform and "n" for Unix platform
% d output the date or time of the log point in time. The default format is ISO8601, or you can specify the format after that, for example:% d {yyy MMM dd HH:mm:ss,SSS}. The output is similar: October 18, 2002, 22, 14, 10, 14, 28, 921.
% l outputs where the log event occurs, including the class name, the thread that occurred, and the number of lines in the code. For example: Testlog4.main (TestLog4.java:10)
% F the name of the file in which the output log message was generated
% L output line number in code
% x outputs the NDC (nested diagnostic environment) associated with the current thread, as in java servlets multiclient multithreaded applications
%% outputs a'% 'character
You can add modifiers between% and pattern characters to control its minimum width, maximum width, and text alignment. Such as:
% 5c: output category name with a minimum width of 5 category
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.