Log test

The new test method recently get logs, share it!


 

A. Why do we log the test?

Although additional logging may lead to the execution speed of software programs decline. But if there is a detailed logging can help us diagnose problems more quickly, accelerate our response to a failure, and can often be significantly reduced discover some hidden very deep wrong question!

 

II. Log level

log4j defines eight levels of log (removal and OFF ALL, can be said to be divided into six levels), order of highest to lowest priority: OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL.

ALL lowest level, to open all logging.

 

TRACE designates finer-grained informational events than the DEBUG.Since: 1.2.12, the log level is very low, generally do not use.

DEBUG pointed out that fine-grained information events for debugging applications are very helpful, mainly for the development process of the print run of some information.

INFO messages on a coarse-grained level to highlight the process of running the application. Print some of your interesting or important information, this information may be used in some important production environments running output, but not abuse, avoid printing too many logs.

WARN indicates that there will be a potential error situations, some information is not an error message, but also to give some tips programmers.

ERROR pointed out that although the error event, but still does not affect the continued operation of the system. Printing error and exception information, you do not want too many log output, you can use this level.

FATAL pointed out that every serious error occurs if exiting the application. This level is relatively high. Major error, this level you can stop the program directly.

OFF highest level for close all logging.

 

If the log level is set at a certain level, then this higher level than the priority log can be printed out. Generally the test environment is set to DEBUG level, the official client environment is set to ERROR level.

 

III. How to view the log?

 

windows direct use Notepad ++, UE editor to view the log files on it, the following detailed description of linux system log To view:

1. connect to a server using ssh

2. After the connection is successful, using the cd to catalina.out file tomcat / logs / in

3. Use the tail command to view the log file, such as tail -f catalina.out, by default displays the last 10 lines of the log, -f parameter can be recycled read the log, all logs are generated by the output current. To view the contents of a log file in the row N already exists, can use the command tail -f -n 1000 catalina.out (1000 lines view the contents of the file, and the current cycle of the output produced by the log)

4. Some sporadic problems, when we submit bug, error stack can upload screenshots to help developers quickly locate the problem.

 

IV. Common types of errors

 

Guess you like

Origin www.cnblogs.com/jitipaper/p/11973179.html