Monday, June 3, 2013

Logback - Setting for Spring3.1.4

    <properties>
        <org.slf4j.version>1.7.5</org.slf4j.version>
        <org.logback.version>1.0.13</org.logback.version>
    </properties>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${org.logback.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${org.logback.version}</version>
        </dependency>


#logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>

  <appender name="HADOOP_FLUME" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${user.dir}/logs/flumeAdmin.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <!-- daily rollover -->
        <fileNamePattern>${user.dir}/logs/flumeAdmin.log.%d{yyyy-MM-dd}.log.zip</fileNamePattern>
        <!-- keep 90 days' worth of history -->
        <maxHistory>90</maxHistory>
    </rollingPolicy>
    <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
        <charset>UTF-8</charset>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg%n</pattern>
        </layout>
    </encoder>

  </appender>

  <root>
      <level value="info" />
    <appender-ref ref="HADOOP_FLUME" />
  </root>

</configuration>

No comments:

Post a Comment