Log4j

xiaoxiao2021-03-17  221

Log4j is an excellent open source Java log system, and the JBoss is also integrated. The default is only a daily log for Server under JBoss, and there is no daily log building for your deployment, but we can pass Modify the log4j.xml file to implement. Log4j.xml file Open Log4j.xml file under Server / Default / Conf in the JBoss installation directory

This is the default configuration of log4j, let's get familiar with it.

< ! - ============================== ->

Output mode: output to the console ->

Set channel name: console and output: org.apache.log4j.rollingFileAppender where there are 5 types of Appender, org.apache.log4j.consoleAppender org.apache.log4j.fileappender (file) Org.apache .log4j.dailyRollingFileAppender (a log file is generated every day) org.apache.log4j.writraPpender (send log information to any specified place in flow format) ->

It is a global filter that will not be displayed below the information below the set Level. ->

Configure the format of log output ->

The parameters have different parameters after the beginning of the parameters represent different formatted information (parameters are listed in alphabetic order):

% C

Output the full name of the class, can be modified to% D {NUM}, the NUM class name output, such as "org.apache.ely.classname",% c {2} will output Elathen.ClassName% D Output log time Its format is% d {YYYY-MM-DD HH: MM: SS, SSS}, can specify a format as% D {HH: mm: SS}% L Output log event occurs, including category names, threads, The number of rows in the code% n wrap% m output code specifies information, such as info ("message"), output Message% P output priority, ie Fatal, Error and other% R output from start to display the log information Mixing% t outputs thread name generated by the log event

->

->

The above is the default configuration of Log4j under JBoss. Logging for JBoss's Server, let's add the log of the web project, add the following configuration information in the log4j.xml file.

转载请注明原文地址:https://www.9cbs.com/read-129678.html

New Post(0)