All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.smallmind.scribe.spring.logging.xml Maven / Gradle / Ivy

The newest version!
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

  <!-- Filters -->
  <bean id="exceptionSuppressingLogFilter" class="org.smallmind.scribe.pen.ExceptionSuppressingLogFiltergFilter"/>

  <!-- Logging Templates -->
  <bean id="defaultTemplate" class="org.smallmind.scribe.pen.DefaultTemplate" init-method="register">
    <property name="autoFillLogicalContext" value="true"/>
    <property name="appenders">
      <list>
        <ref bean="fileAppender"/>
        <ref bean="errorFileAppender"/>
      </list>
    </property>
    <property name="filters">
      <list>
        <ref bean="exceptionSuppressingLogFilter"/>
      </list>
    </property>
    <property name="level" value="${log.default.level}"/>
  </bean>

  <bean id="dynamicTemplate" class="org.smallmind.scribe.spring.DynamicClassNameTemplateInitializingBeanalizingBean">
    <property name="autoFillLogicalContext" value="true"/>
    <property name="appenders">
      <list>
        <ref bean="fileAppender"/>
        <ref bean="errorFileAppender"/>
      </list>
    </property>
    <property name="filters">
      <list>
        <ref bean="exceptionSuppressingLogFilter"/>
      </list>
    </property>
  </bean>

  <!-- Logging Framework Setup -->
  <bean id="shortTimestamp" class="org.smallmind.scribe.pen.DateFormatTimestamp">
    <property name="dateFormat">
      <bean class="java.text.SimpleDateFormat">
        <constructor-arg index="0" value="yyyy-MM-dd"/>
      </bean>
    </property>
  </bean>

  <bean id="fullTimestamp" class="org.smallmind.scribe.pen.DateFormatTimestamp">
    <property name="dateFormat">
      <bean class="java.text.SimpleDateFormat">
        <constructor-arg index="0" value="yyyy-MM-dd'T'HH:mm:ss.SSSZ"/>
      </bean>
    </property>
  </bean>

  <bean id="xmlFormatter" class="org.smallmind.scribe.pen.XMLFormatter">
    <property name="indent" value="0"/>
    <property name="newLine" value=""/>
    <property name="timestamp" ref="fullTimestamp"/>
    <property name="cdata" value="true"/>
  </bean>

  <bean id="patternFormatter" class="org.smallmind.scribe.pen.PatternFormatter">
    <property name="timestamp" ref="fullTimestamp"/>
    <property name="format" value="%d %n %+5l (%F.%M:%L) [%T] - %m%!+\n\t!p%!+\n\t!s"/>
  </bean>

  <bean id="rollover" class="org.smallmind.scribe.pen.Rollover">
    <property name="timestamp" ref="shortTimestamp"/>
    <property name="separator" value="."/>
    <property name="rules">
      <list>
        <bean class="org.smallmind.scribe.pen.TimestampRolloverRule">
          <property name="timestampQuantifier" value="${log.rollover.period}"/>
        </bean>
        <bean class="org.smallmind.scribe.pen.FileSizeRolloverRule">
          <property name="fileSizeQuantifier" value="MEGABYTES"/>
          <property name="maxSize" value="10"/>
        </bean>
      </list>
    </property>
  </bean>

  <bean id="warnLevelFilter" class="org.smallmind.scribe.pen.LevelFilter">
    <property name="level" value="WARN"/>
  </bean>

  <bean id="consoleErrorHandler" class="org.smallmind.scribe.pen.DefaultErrorHandler">
    <property name="backupAppender" ref="consoleAppender"/>
  </bean>

  <bean id="consoleAppender" class="org.smallmind.scribe.pen.ConsoleAppender">
    <property name="formatter" ref="patternFormatter"/>
  </bean>

  <bean id="fileAppender" class="org.smallmind.scribe.pen.AsynchronousAppender">
    <constructor-arg index="0" name="internalAppender">
      <bean class="org.smallmind.scribe.pen.FileAppender">
        <property name="logFile" value="${log.dir}/${log.file}.txt"/>
        <property name="rollover" ref="rollover"/>
        <property name="formatter" ref="patternFormatter"/>
        <property name="errorHandler" ref="consoleErrorHandler"/>
      </bean>
    </constructor-arg>
    <constructor-arg index="1" name="bufferSize" value="${log.buffer_size}"/>
  </bean>

  <bean id="errorFileAppender" class="org.smallmind.scribe.pen.FileAppender">
    <property name="logFile" value="${log.dir}/${log.file}-error.txt"/>
    <property name="rollover" ref="rollover"/>
    <property name="filter" ref="warnLevelFilter"/>
    <property name="formatter" ref="patternFormatter"/>
    <property name="errorHandler" ref="consoleErrorHandler"/>
  </bean>

  <bean id="fileErrorHandler" class="org.smallmind.scribe.pen.DefaultErrorHandler">
    <property name="backupAppender" ref="errorFileAppender"/>
  </bean>
</beans>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy