In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use log4j2 to close the debug log", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use log4j2 to close the debug log" bar!
Log4j2 closes the debug log
Recently, the project was imported into a jar package, and the debug log could not be stopped after startup, and it took half an afternoon to close the log. Summarize the following treatment methods for your reference:
1. If logback's jar package is introduced, exclude references (there are no references in my project)
Ch.qos.logback logback-classic ch.qos.logback logback-core
two。 Adjust the log print level of log4j2, log4j2.xml (it doesn't work for my project)
3. Add the specified log file to the specified load file web.xml (my project is invalid)
Log4jConfigLocation WEB-INF/classes/log4j2.xml org.springframework.web.util.Log4jConfigListener
4. Add log4j.properties (valid for my project)
Log4j.rootLogger=info,stdout
Note: because the third-party jar package introduces conflicts between slf4j-log4j12 and log4j2 in my project, it is possible to exclude without the slf4j-log4j12 jar package.
Debug log issues for Log4J and slf4j
As many people know, two jar packages are usually introduced in the process of using slf4j, roughly as follows:
Org.slf4j slf4j-api 1.7.21 org.slf4j slf4j-simple 1.7.21
When using the final logging implementation, such as Log4j, the log4j-related jar package will be introduced, as follows:
Log4j log4j 1.2.17 org.slf4j slf4j-log4j12 1.7.21
This allows you to output logs written by slf4j in Java applications (Java Web services and Java programs).
But in the process of use, found that in the execution of test cases (loading Spring or not loaded Spring), no matter how to configure the log4j.properties file, there will be part of the debug log output can not be, specifically, that part of the debug log will not be output, and frameworks such as Spring or MyBatis debug log can be exported.
Later, according to the warning log of slf4j, it is said that there are multiple log implementations, so it is not clear which specific log implementation to choose. After further debugging and removing the slf4j-simple dependency, all debug logs can be output as scheduled.
Thank you for reading, the above is the content of "how to use log4j2 to close the debug log". After the study of this article, I believe you have a deeper understanding of how to use log4j2 to close the debug log, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.