How to configure and initialize: There are three kinds of configurations: Configuration program, java configuration files, xml configuration file. Java profiles usually simple, I like it. About initialization in a web application, the official website of the log4j manual (in English) webwing translation of the Chinese version. There is a detailed example, it is worth learning. Initialization servlet section. The simplest configuration: the configuration momo film file named log4j.configuration, put under the WEB-INF / classes, all OK! Do not have to use the first two methods to initialize. momo film java configuration momo film file using PropertyConfigurator, xml configuration file using DOMConfigurator. You can also use BasicConfigurator.configure momo film (); to use the basic configuration, but most do not use it. Category Logger class is a subclass of class, will gradually replace the Category class, there are many examples of the previous configuration with Category, it is recommended to use the Logger class are now. Several APPENDERS (refer to the example http://blog.csdn.net/kengking/archive/2004/11/15/LOG4J.aspx) Console: org.apache.log4j.ConsoleAppender Files: org.apache.log4j.FileAppender GUI components: ...... Remote socket servers: ...... NT Event Loggers: ...... Remote UNIX Syslog daemons: ...... PatternLayout format (like the difference between a)
The number of milliseconds since the program description% r% t after the start of consumption, said the logging request priority thread% p generated log statements indicate% c log where the class name% m% n represents the contents of the log information from the application starts% r The output of the log information to the date or time consuming milliseconds% d log point in time, the default format is ISO8601, you can then specify the format, such as:% d {yyy MMM dd HH: mm: ss, SSS}, output Similar: October 18, 2002 22: 28,921% l happen location log events, including the category name, the threads, as well as the number of lines in the code: 10.
Logger Logger used in the program to get the instance -> output debugging information, including: DEBUG, INFO, WARN, ERROR, momo film FATAL total of five, usually INFO enough. Logger program created by Logger logger = Logger.getLogger (this.getClass () getName ().); (If there LogFactory can use this class to generate, for example:. momo film Private Log log = LogFactory.getFactory () getInstance (this .getClass () getName ());.) If the JVM is not the Logger will create a new Logger. When you create a Logger, if the configuration file there is this logger, momo film press configuration to create, otherwise inherits rootLogger. Relatively high efficiency of this code, debug information is not required in the future when it is most efficient. if (logger.isInfoEnabled ()) logger.info (this.getClass momo film () getName ().);
All topics Hadoop AWS mobile games Java Android iOS Swift intelligent hardware Docker OpenStack VPN Spark ERP IE10 Eclipse CRM JavaScript database Ubuntu NFC WAP jQuery BI HTML5 Spring Apache .NET API HTML SDK IIS Fedora XML LBS Unity Splashtop UML components Windows Mobile Rails QEMU KDE Cassandra CloudStack FTC coremail OPhone CouchBase cloud iOS6 Rackspace Web App SpringSide Maemo Compuware momo film large data aptech Perl Tornado Ruby Hibernate ThinkPHP HBase Pure Solr Angular momo film Cloud Foundry Redis Scala Django Bootstrap
Read Top Unicode / UTF-8 difference momo film of (3714) Spring comes JPetStore analysis momo film (a) (3002) Spring MVC notes (2921) Eclipse used Juint (2739) Log4j in Java Web Development using notes (2593) Struts The javax.servlet.servletexception: can not find actionmappings or actionformbeans collection error (1881) Spring comes JPetStore analysis (b) (1847) Spring comes JPetStore analysis (c) cross-compile a static library under protobuf (1650) mac. Protobuf solve the iPhone 5s, iPad air, iPad mini2 crash problem. (1551) momo film Struts introductory article momo film series (link) and the study notes (1413)
Top Spring MVC notes Comments (2) Log4j Java Web development in the use of notes (2) cross-compile a static library under protobuf mac. Protobuf solve the iPhone 5s, iPad air, iPad mini2 crash problem. (1) New Beginning (1) start to see some examples of (1) [Reserved] Struts simple analysis (0) Spring comes JPetStore analysis (four) (0) beginner Python notes (a) (0) Unicode / UTF -8 difference (0) UTF-8 and Unicode FAQ (0)
No comments:
Post a Comment