Label: log4j
I. Introduction Log4j is an open-source project of Apache. By using log4j, we can control the log information delivery destination, including the console, files, Gui components, and even the interface service set, NT event recorder, and Unix Syslog daemon; we can also control the output format of each log. By defining the level of each log information, we can control the log generation process in more detail.Log4j consists of three important components: log information priority,
code:Foo(): print(' I am foo 'logging. Info("foo is running") If the function bar () and BAR2 () have similar requirements, how do you do it? Write another logging in the bar function? This creates a lot of identical code, and in order to reduce the duplication of code, we can do this and redefine a new function: To handle the log, and then execute the real business code after the log is processed. def use_logging (func): span class= "n" >logging.
Learn a new technique or language, we must first learn how to adapt to this new technology, which in the adaptation process, we have to learn how to debug the program and play the corresponding log information, is called "as long as the log is good, no bugs can not solve", in our well-known information technology, The Log4xxx series, as well as the Android.util.Log packages for Android apps, are all for developers to get a better log information service. In the language of Python, we can also pl
trace doesn't use it at all. Is it okay to use the debug feature of Eclipse or idea?
Info: Output The information you are interested in or important, which is the most used.
Warn: Some of the information is not an error message, but there are also some hints for the programmer, similar to the validation of the code in eclipse that there is no error or warn (not a mistake but also note, for example, the fol
First reprint the JMeter log settings:JMeter run problems can be fixed by adjusting the JMeter log level, but it is recommended to close the JMeter log when you run the test, jmeter the print log consumes system performance.The JMeter log is stored by default in the%jmeter_home%\bin directory, and the file name is usually JMeter.log. Logging information about the operation of the JMeter itself.JMETER uses the log4j log component output log, Log_level.jmeter in%jmeter_home%\bin\jmeter.properties
LOG4J Component Composition
The log4j is composed of three important components:
1. Priority of log information (Logger)
2. Output Destination of log information (Appender)
3. The output format of the log information (Layout).
Profile:
The priority of log information from high to low has error, WARN, INFO, DEBUG, respectively, to specify the importance of this log information;
The output destination of the log information specifies whether the
root category (at the top of the category hierarchy, that is, the global log level)Configure the root logger, whose syntax is:
Log4j.rootlogger = [level], Appendername, Appendername, ...
Level is the category of the log recordAppendername is where you specify the output of the log information. You can specify multiple output destinations at the same time.
The category level is off, FATAL, ERROR, WARN, INFO, DEBUG, log, all, or custom precedence.Og4j
http://www.qinbin.me/log4php-use-and-configuration-guide/
has been a temporary write the log component, but now with the continuous improvement of the function, the program's log also made the specification, but feel that the current log function can not meet the needs of the present, so consider introducing a comprehensive log components, look at the log4php feel very good.
Log4php is one of the LOG4XX series log components, the log4j migration to PHP version, mainly used to record log info
LogLevel used to adjust the level of detail in the information that is recorded in the error log
Level Description ExampleEmerg emergency-System not available. "Child cannot open lock file. Exiting "Alert must take immediate action. "Getpwuid:couldn ' t determine user name from UID"Crit fatal condition. "Socket:failed to get a socket, exiting child"Error condition. "Premature end of script headers"Warn warning condition. "Child process 1234 did not e
I. Overview
1, the use of SLF4J as a log API, using Logback as a log output tool, with SLF4J Bridge to replace the log4j and commons-logging.
2, using trace (Tracking), debug (Debug), info (information), warn (warning), error (Error), Fatal (fatal) a total of 6 log levels.
3, the use of dev (development environment), test (testing environment), production (production environment) and other different log configuration, according to the environment var
Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method)
At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)
At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:25)
At Java.lang.reflect.Method.invoke (method.java:597)
At Org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod (retryinvocationhandler.java:82)
At Org.apache.hadoop.io.retry.RetryInvocationHandler.invoke (retryinvocationhandler.java:59)
At $Proxy 0.addBlock
Rs. Close ();
// Close the statement
Stmt. Close ();
// Close the connection
Con. Close ();}Catch (sqlexception ex ){
// Generate sqlexception. Capture it and// Display the error message. Note:// There may be multiple error object links// Together
System. Out. println ("/n *** sqlexception caught ***/N ");
While (ex! = NULL ){System. Out. println ("sqlstate:" +Ex. getsqlstate ());System. Out. println ("message:" + ex. getmessage ());System. out. println ("Vendor:" +Ex. getErrorCode ());Ex = ex.
and catch do not have to be handled.Like code,Try {FileWriter fw = new FileWriter ("k.txt ");}Catch (IOException e) {} // catch is empty, and it is not processed.
2. What exceptions are thrown, such as capturing multiple exceptions?
(1) The complete code is as follows:
File file = new File ("d: \ a.txt"); // This Is Not A read object and will not throw an exception. Only when it is possible to throw an exception can catch the object, otherwise, the excess catch eclipse will also report the err
Tips for maintaining CentOS 7Bwm-ng
: Https://www.gropp.org /? Id = projects sub = bwm-ngDownload, compile, and installTerminal execution
bwm-ng
By default, the unit is KB/s, which can be switched. There are some other operations,Htop
: Http://hisham.hm/htop/ download, compile, install the terminal to execute
htop
You can use the mouse and keyboard to perform operations, which is much more convenient than the native top. You can use F4. F9 can then directly filter and kill the process. Less
Thi
Log4j is an open-source log component developed by Apache. log4j can control the delivery of log information to the console, files, and GUI components, and control the output format of each log; the configuration file can be used for flexible configuration to control the log generation process in greater detail. The following is a record of my basic usage of log4j.
1. First import the frame package of the log4j-1.2.14.jar into the project.
2. Create the log4j. properties configuration file under
An environment is deployed locally, and apachephp runs normally. Echophpinfo(javaspboard.png] (imgbVF2CF) cannot be opened when the local website environment is opened. for example, why does the ssl module already be enabled in xampp? ApacheerrorlogAH00112: Warning: D...
An environment is deployed locally, and apache php is running normally. Echo phpinfo ()Pboard.png] (/img/bVF2CF)
However, it cannot be opened when the local website environment is opened: for example:
The ssl module has been en
not have to be handled.Like code,Try {FileWriter fw = new FileWriter ("k.txt ");}Catch (IOException e) {} // catch is empty, and it is not processed.
2. What exceptions are thrown, such as capturing multiple exceptions?
(1) The complete code is as follows:
File file = new File ("d: \ a.txt"); // This Is Not A read object and will not throw an exception. Only when it is possible to throw an exception can catch the object, otherwise, the excess catch eclipse will also report the error BufferedRe
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.