Skip to main content

 Advanced

Advanced topics

Logback

/WEB-INF/config/logback-[mode].xml

All the content generators in Berlioz/Bastille use a logging facade (slf4j ) so that the logging framework can be left at the discretion of the developers.

However, Berlioz automatically loads configuration files for the Logback logging framework using the XML syntax.

See http://logback.qos.ch/manual/configuration.html for details.

Sample config

Here are sample logback configurations.

Development mode

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="true" scanPeriod="30 seconds">
 
  <!-- Context name -->
  <contextName>MyBerliozApp</contextName>
 
  <!-- Sends logs to Logback's Beagle Eclipse plugin -->
  <consolePlugin />
 
  <!-- Console appender -->
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>[%thread] %-5level %logger{30} - %msg %n</pattern>
    </encoder>
  </appender>

  <!-- Some libraries can be chatty... -->
  <logger name="net.sf.ehcache"       level="INFO" />
  <logger name="org.weborganic.flint" level="INFO" />

  <!-- Berlioz -->
  <logger name="org.weborganic.berlioz" level="INFO" />
 
  <!-- Bastille -->
  <logger name="com.weborganic.bastille" level="INFO" />
  <logger name="com.weborganic.bastille.flint" level="WARN" />
 
  <root level="DEBUG">
    <appender-ref ref="STDOUT"/>
  </root>
 
</configuration>

Production mode

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">

  <!-- Context -->
  <contextName>MyBerliozApp</contextName>

  <!-- General Logs (text) -->
  <appender name="GENERAL"
            class="ch.qos.logback.core.rolling.RollingFileAppender">
    <File>logs/berlioz.log</File>
    <Append>true</Append>
    <encoder>
      <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSS} [%thread] %-5level
                %logger{36} - %msg%n
      </pattern>
    </encoder>
    <rollingPolicy class="com.weborganic.logback.PSRollingPolicy">
      <fileNamePattern>logs/berlioz-%d{yyyy-MM-dd}.%i.log
      </fileNamePattern>
      <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
        <maxFileSize>10MB</maxFileSize>
      </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>
  </appender>

  <root level="INFO">
    <appender-ref ref="GENERAL"/>
  </root>

</configuration>
Created on , last edited on