This is the default configuration of log4j, let's familiarize ourselves with <!--==============================--> <!--Append messages to the console--> <!--==============================--> <!--output mode: Output to console--> <appender name= "CONSOLE" class= "Org.apache.log4j.ConsoleAppender" > <!--Set Channel name: Console and output mode: Org.apache.log4j.RollingFileAppender There are 5 kinds of appender in the output mode, respectively Org.apache.log4j.ConsoleAppender (console) Org.apache.log4j.FileAppender (file) Org.apache.log4j.DailyRollingFileAppender (Generate a log file every day) Org.apache.log4j.WriterAppender (sends log information to any specified place in streaming format)--> <param name= "Target" value= "System.out"/> <param name= "Threshold" value= "INFO"/> <!--threshold is a global filter that filters out information that is lower than the level you set and does not show up--> <!--level: is the priority of the journal record, the priority from high to low divided into Off, FATAL, ERROR, WARN, INFO, DEBUG, all. LOG4J recommends using only the four levels of fatal, ERROR, WARN, INFO, and Debug. --> <layout class= "Org.apache.log4j.PatternLayout" > <!--Configure log output format--> Parameters represent different formatting information (the parameters are listed in alphabetical order) with different parameters after the start of%: The full name of the class to which the%c output belongs can be modified to%d{num}, and the Num class name output is surrounded as: "Org.apache.elathen.ClassName", %C{2} will output elathen. ClassName %d output log time in the format of%d{yyyy-mm-dd hh:mm:ss,sss}, you can specify a format such as%d{hh:mm:ss} %l output Log event occurrence location, including class name, occurrence thread, number of lines in code %n line break %m output code to specify information, such as info ("message"), output message %p output priority, that is, FATAL, ERROR, etc. %r output the number of milliseconds it takes to display the log information from boot to %t output The name of the thread that generated the log event <!--the default pattern:date Priority [Category] message/n--> <param name= "Conversionpattern" value= "%d{absolute}%-5p [%c{1}]%m%n"/> </layout> </appender>
<! output is: A daily log file > <!--A time/date based rolling Appender--> <appender name= "FILE" class= "Org.jboss.logging.appender.DailyRollingFileAppender" > <!--set the channel name is: file, output mode dailyrollingfileappender--> <param name= "File" value= "${jboss.server.home.dir}/log/server.log"/> <!--log file path and file name--> <param name= "Append" value= "false"/> <!--set whether to add a new log on the basis of the original log when the service is restarted--> <!--rollover at midnight--> <param name= "Datepattern" value= ". Yyyy-mm-dd "/>
<!--rollover at the top of each hour <param name= "Datepattern" value= ". Yyyy-mm-dd-hh "/> -->
<layout class= "Org.apache.log4j.PatternLayout" > <!--the default pattern:date Priority [Category] message/n--> <param name= "Conversionpattern" value= "%d%-5p [%c]%m%n"/> <!--the full pattern:date MS Priority [Category] (THREAD:NDC) message/n <param name= "Conversionpattern" value= "%d%-5r%-5p [%c] (%t:%x)%m%n"/> --> </layout> </appender>
|