information objects, especially for log frames (log4j 1, commons-logging) that do not support parameterized information. As the following example shows, if the debug level is not determined, the second line of code in the Environment (production environment) that is disabled at the debug level will not produce multiple string objects as necessary.if (logger.isde
includes off, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, and all. In general, the level of use is FATAL, ERROR, WARN, INFO, DEBUG, and TRACE. These 6 levels correspond to a different situation:
FATAL: A serious error that causes the program to end prematurely.
Error: Run-time exceptions and unexpected errors.
WARN: The expected run-time status is not necessarily the wrong case.
INFO: Events that occur at
Log4j is the de facto Java standard logging tool. Is it possible to use log4j to a certain extent, it is a standard to measure whether a developer is a qualified Java programmer. If you're a Java programmer, if you're not using log4j, then you really need to read this article. Many friends reflect want to write the program lo
}web-inf/logs/error.log log4j.appender.e.file.maxfilesize=500kblog4j.aPpender. E.append = true## Only output logs above the error level!!! Log4j.appender.e.threshold = Errorlog4j.appender.e.layout = Org.apache.log4j.patternlayoutlog4j.appender.e.layout.conversionpattern =%-d{yyyy-mm-dd HH:mm:ss} [%t:%r]-[%p]%m %nlog4j.appender.e.encoding=utf-8Configure the Info-level output to the console, and debug and error are output to the corresponding file. 4. U
Java implements an account that can only log on to the same region, go offline elsewhere, and go offline in java
In fact, there are a lot of methods, and I am ugly.
Use to understand the four major scopes of java.
Idea: understand the key to the Four Scopes of java.
First pl
Java log Combat and analysis
Log is one of the basic skills that programmers must master, and if you write software without a log, you can say you are not a real programmer.
Why do I have to keep a diary?
• Monitoring code
• Variable variation, system operation process.
• Production line environment, not very good deb
First, log4j configuration
The first step: Join Log4j-1.2.8.jar to Lib.
Step two: Establish the log4j.properties under the classpath. The contents are as follows:
If you put it under SRC, you don't have to configure it or you have to go to Web.xml to configure a listener
Reference:
Log4j.rootcategory=info, stdout, R log4j.appender.stdout=org.apache.log4j.consoleappender log4j.appender.stdout . Layout=org.apache.log4j.patternlayout LOG4J.APPENDER.STDOUT.LAYOUT.CONVERSIONPATTERN=[QC]%p [%t]%C.%M
experience. It is more convenient to use, more powerful, and higher performance. Logback cannot be used alone and must be used in conjunction with the log frame slf4j.
--------------------------------------------------------------------------------------------------------------- --------
References a description of Java log in an article.
In order to overcome t
, it has a feature that you might find relevant to the log.For the log Analysis tool, the biggest drawback is that you have to have logs to analyze. From the perspective of the integrated development environment, if there is no exception report, or no error message data, you can not know where the problem, so that any tool in the world can not help you! The Debug is stuck here. :(One of the advantages of TA
Integration principles of slf4j and Jul, log4j1, log4j2 and LogbackSlf4jLet's start with a simple use case to explain2.1 Simple Use Casesprivate static Logger Logger=loggerfactory.getlogger (Log4jslf4jtest.class);public static void Main (string[] args) {if (logger.isdebugenabled ()) {Logger.debug ("slf4j-log4j debug Message");}if (logger.isinfoenabled ()) {Logger.debug ("slf4j-log4j info message");}if (logger.istraceenabled ()) {Logger.debug ("slf4j-l
exception handlingFor example:try{......}catch (Exception e) {throw new Exception (msg,e);Return "";}Mixed use of Java exception handling mechanisms and return values makes the exception handling part of the program "ugly" and difficult to understand. If there are many different exceptions, define a number of different exceptions instead of using exception and return values in the same way as the code above.Third,
log4j Log output in Java console, simple and practical
1, log4j output has 2 in the way: the first is to save the log information in a text, the second is output to the console. The second way is described below.
2, in the console output log4j log information, is commonly used in development projects is also a must be
that is above or equal to the set level, the higher the log level of the set level, the printed day If the log information of the set level info can be output, less than that level, such as debug will not be output, to ensure that all logger can be Eventually inherits a level, so the root logger always has a level, in general, this level is the
Common-loggingcommon-logging is a common log interface provided by Apache. The user is free to choose the third party's log component as a concrete implementation, like log4j, or the logging that comes with the JDK, common-logging will automatically find the log library that is actually used when the program runs by dynamic lookup mechanism. Of course, there is a
The version used here is for Log4j-1.2.15,jar resources to get the download. first, the introduction
During the normal development process, sometimes do not want to print all the logs to the same log file, in addition to the Java Engineering Integration log4j 1.x posting introduction of the use of a logger, Configuring multiple Appender Log4j.appender.d.threshold properties, you can also configure multiple
工欲善其事 its prerequisiteThe Java development in the eyes of Stormy, an old Domino programmer, I mentioned the large number of logs that are being encountered in Java development. Server Console Brush-like scrolling, log files grow rapidly, debug when the relevant information is often flooded with examples, in many logger
.
* Private Long Nextcheck = System.currenttimemillis ()-1;
Date now = new Date ();
SimpleDateFormat SDF;
Rollingcalendar rc = new Rollingcalendar ();
/** * The default constructor does nothing. * * Public Minuterollingappender () {}/** * Instantiate a
The test configuration file is as follows:
On the timing of implementation, you can also use Java provided timer implementation, but also eliminates each
Transferred from: http://www.blogjava.net/daiyongzhi/archive/2014/04/13/412364.htmlcommon-logging is a common log interface provided by Apache. The user is free to choose the third party's log component as a concrete implementation, like log4j, or the logging that comes with the JDK, common-logging will automatically find the log library that is actually used whe
Daniel old D, old D found Xiaoc-logging.jar This log framework can meet the basic log requirements, but is not large enough, not some such as automatic archiving, writing files asynchronously, write log files to the NoSQL database medium function. Thereupon the old D developed a more advanced log framework called Oldd
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.