Simple log4j.xml Example

From NovaOrdis Knowledge Base
Revision as of 17:59, 8 November 2016 by Ovidiu (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
        <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
        <param name="Target" value="System.out"/>
        <param name="Threshold" value="INFO"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="@%t %d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
        </layout>
    </appender>

    <!--
    <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
       <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
      <param name="File" value="${test.log.directory}/test.log"/>
      <param name="DatePattern" value="'.'yyyy-MM-dd"/>
      <param name="Threshold" value="DEBUG"/>
      <param name="Append" value="false"/>
      <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="@%t %d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
      </layout>
    </appender>
    -->

    <category name="io.novaordis.example">
        <priority value="WARN"/>
    </category>

    <root>
        <appender-ref ref="CONSOLE"/>
        <!-- <appender-ref ref="FILE"/> -->
    </root>

</log4j:configuration>