jboss_log4j.xml Configuration

log4j is an excellent open source java logging system, also integrated inside his jboss default in jboss server just to do a daily log and no daily log of your deployment project to build, but we can modify jboss -log4j.xml file to achieve.
jboss-log4j.xml file [JBOSS_HOME] \ under server\default\conf, open jboss-log4j.xml file
This is the default log4j settings, we first familiarize yourself
<- Output:! output to the console ->
<appender name = "the CONSOLE" class = "org.apache.log4j.ConsoleAppender tells that">
<-!
    set channel name: console and output: org.apache.log4j.RollingFileAppender
    wherein there are five appender output, respectively
    org .apache.log4j. the ConsoleAppender (console)
    org.apache.log4j. the FileAppender (file)
    org.apache.log4j. DailyRollingFileAppender (generating a log file per day)
    org.apache.log4j. WriterAppender (log information to the stream format any designated place)
->
<param name = "the Target"
! <-
    Threshold is a global filter, he'll lower than the set level of information filtering is not displayed
    level: is the priority diary records, from high to low priority is divided into OFF, FATAL, ERROR, WARN , INFO, DEBUG, ALL.
    Log4j is recommended that only FATAL, ERROR, WARN, INFO, DEBUG four levels.
->
<param name = "the Threshold" value = "the INFO" />
<-!
    Set the log output format
    parameters are to begin% behind different parameters representing different formatting information
    % c output of the full name of the owning class, may be modified to% d {Num}, Num class name surrounded output  
       such as: "org.apache.elathen.ClassName",% C { 2} the output elathen.ClassName                
    % D output log time format of% d {yyyy -MM-dd HH: mm: ss , SSS}, to specify the format as {D HH%: mm: SS}
    % L output log incident position, comprising a category name, place of threads, the number of lines in the code
    % n newline
    % m output code specifying information, such as the info ( "message"), the output message
   % P output priority, i.e. FATAL, ERROR, etc.
    % r output the log information on the number of milliseconds spent from the start to the display
    % t generate the output log event thread name
->
<layout class = "Org.apache.log4j.PatternLayout">
    <param name = "ConversionPattern" value = "% D%} {the ABSOLUTE -5p [{C%. 1 }]%% n-m "/>
</ layout>
</ the appender>

! <output is: a daily log file>
<the appender name =" the fILE "class =" org.jboss.logging.appender.DailyRollingFileAppender ">
    < ! - name of the channel is provided: file, log file path and file name ->
    <param name = "file" value = "$ {jboss.server.home.dir /log/server.log}" />
    <! - Sets whether the service is restarted, add in the original log new log (value = "false") ->
    <param name = "Append" value = "false" />
    <param name = "DatePattern" value = " '.’yyyy-MM-dd"/>
    <layout class="org.apache.log4j.PatternLayout">
        <param name = "ConversionPattern" value = "% D% -5p [% C]%% n-m" />
        <param name = "ConversionPattern" value = "% D%% -5p 5R- [% C] (% T: X%)%% n-m "/>
    </ layout>    
</ the appender>
the above is the default setting in jboss-log4j.xml jboss, jboss logging server to

increase SQL DML statements log (added directly to jboss- log4j.xml file, remove the comments to Chinese)
<! - written document ->
<appender name = "SQL_LOG" class = "org.jboss.logging.appender.RollingFileAppender">
    <param name = "file" value = "$ {jboss.server.home.dir /log/sql.log}" />
    <param name = "the Append" value = "to false" />
    <param name = "the MaxFileSize" value = "500KB" />
    < param name = "MaxBackupIndex" value="1"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
    </layout>    
< /appender>

< !--控制台输出-->
< appender name="sql_console" class="org.apache.log4j.ConsoleAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="Target" value="System.out"/>
      <param name="Threshold" value="DEBUG"/>
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
      </layout>
   </appender>

< !-       <Level value = "DEBUG" />       <-! Define the output level ->    <category name = "org.hibernate.SQL">Hibernate Log Categories SQL uppercase ->



      <!-- 定义引用的Appender -->
      <appender-ref ref="sql_console"/>
      <appender-ref ref="sql_log"/>  
< /category>

定义web项目的日志
<appender name="custome" class="org.jboss.logging.appender.RollingFileAppender">
    <param name="File" value="${jboss.server.home.dir}/log/custome.log"/>
    <param name="Append" value="false"/>
    <param name="MaxFileSize" value="500KB"/>
    <param name="MaxBackupIndex" value="1"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
    </layout>    
< /appender>

< category name="com.ljh" >
      <level value="DEBUG" />
      <appender-ref ref="custome"/>
< /category>

Guess you like

Origin www.cnblogs.com/firstdream/p/10935212.html