<log4net>
  <root>
    <!-- Here can be defined the appenders that will be involved in ALL logging request -->
    <level value="ALL" />
    <appender-ref ref="DynamicFileAppender" />
    <appender-ref ref="DynamicDataLogFileAppender" />
    <appender-ref ref="ConsoleAppender" />	
	<appender-ref ref="DynamicFileBufferingAppender" />
	<appender-ref ref="DynamicDataLogFileBufferingAppender" />
  </root>

  <!-- 
                        *************************
                        **  A P P E N D E R S  **
                        *************************
  -->
  <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
    <layout type="Ubiquis.Kernel.Core.Log4Net.SbfLog4NetPatternLayout">
      <conversionPattern value="%DateTime%Tab%EventType%Tab%Section%Tab%EventId%Tab%message%newline" />
    </layout>
  </appender> 

  <!-- Defines an appender that will log any event that *IS NOT* a dataLog into user-defined loggers -->
  <appender name="DynamicFileAppender" type="Ubiquis.Kernel.Core.Log4Net.SbfLogDynamicallyNamedFileAppender">
    <!-- Use a homemade filter to reject dataLogs -->
    <filter type="Ubiquis.Kernel.Core.Log4Net.SbfLog4NetDataLogFilter">
      <allow value="false" />
    </filter>
    <!-- Define the layout to use for event logs -->
    <layout type="Ubiquis.Kernel.Core.Log4Net.SbfLog4NetPatternLayout">
      <conversionPattern value="%DateTime%Tab%EventType%Tab%Section%Tab%EventId%Tab%message%newline" />
    </layout>
    <!-- The filename is not set here, it will be set at runtime -->
  </appender>


  <!-- Defines an appender that will log dataLogs into user-defined loggers -->
  <appender name="DynamicDataLogFileAppender" type="Ubiquis.Kernel.Core.Log4Net.SbfLogDynamicallyNamedFileAppender">
    <!-- Use a homemade filter to filter only the datalogs -->
    <filter type="Ubiquis.Kernel.Core.Log4Net.SbfLog4NetDataLogFilter">
      <allow value="true" />
    </filter>
    <!-- Define the layout to use for dataLogs -->
    <layout type="Ubiquis.Kernel.Core.Log4Net.SbfLog4NetPatternLayout">
      <conversionPattern value="%DateTime%Tab%message%newline" />
    </layout>
    <!-- The filename is not set here, it will be set at runtime -->
  </appender>


  <!-- Defines an appender that will log event logs into the server.log -->
  <appender name="ServerFileAppender" type="Ubiquis.Kernel.Core.Log4Net.SbfLogFileAppender">
    <fileName value="server.log" />
    <!-- Define the layout to use for event logs -->
    <layout type="Ubiquis.Kernel.Core.Log4Net.SbfLog4NetPatternLayout">
		<!--<conversionPattern value="%DateTime%Tab%EventType%Tab%Section%Tab%EventId%Tab%message%newline" />-->
		<!--<conversionPattern value="%utcdate [%thread] :%EventId %-5level :%Section :%logger :%message%newline" />-->
		<conversionPattern value="%utcdate[%thread][%EventId][%-5level][%Section][%logger]%message%newline" />
	</layout>
  </appender>

  <!-- Defines an appender that will log event logs into the debug.log -->
  <appender name="DebugFileAppender" type="Ubiquis.Kernel.Core.Log4Net.SbfLogFileAppender">
    <fileName value="debug.log" />
    <!-- Define the layout to use for event logs -->
    <layout type="Ubiquis.Kernel.Core.Log4Net.SbfLog4NetPatternLayout">
      <conversionPattern value="%DateTime%Tab%EventType%Tab%Section%Tab%EventId%Tab%message%newline" />
    </layout>
  </appender>

  <!-- Defines an appender that will log dataLogs into the recover.log -->
  <appender name="DataLogFileAppender" type="Ubiquis.Kernel.Core.Log4Net.SbfLogFileAppender">
    <fileName value="recover.log" />
    <layout type="Ubiquis.Kernel.Core.Log4Net.SbfLog4NetPatternLayout">
      <conversionPattern value="%DateTime%Tab%message%newline" />
    </layout>
  </appender>

  <!-- Defines an appender that will log exceptions into the exceptions.log -->
  <appender name="ExceptionFileAppender" type="Ubiquis.Kernel.Core.Log4Net.SbfLogFileAppender">
    <fileName value="exceptions.log" />
    <layout type="Ubiquis.Kernel.Core.Log4Net.SbfLog4NetPatternLayout">
      <conversionPattern value="%DateTime%Tab%EventId%newline&lt;&lt;&lt;&lt;%newline%ExceptionFullStackTrace%newline%ExceptionErrorTrace%newline%&gt;&gt;&gt;&gt;%newline" />
    </layout>
  </appender>
  
  <!--  Gestion du buffering (pour controler le flushing dans le code) -->
  <appender name="DynamicFileBufferingAppender" type="log4net.Appender.BufferingForwardingAppender">
      <lossy value="false"/>
      <appender-ref ref="DynamicFileAppender" />
  </appender>
  
  <appender name="DynamicDataLogFileBufferingAppender" type="log4net.Appender.BufferingForwardingAppender">
      <lossy value="false"/>
      <appender-ref ref="DynamicDataLogFileAppender" />
  </appender>

  <!-- 
                        *********************
                        **  L O G G E R S  **
                        *********************
  -->
  
  <!-- The configuration of kernel's root is used to exclude dynamic appenders (additivity = false) -->
  <logger name="kernel" additivity="false">    
    <appender-ref ref="ConsoleAppender" />
  </logger>

  <logger name="kernel.server">
    <appender-ref ref="ServerFileAppender" />
  </logger>

  <logger name="kernel.debug">
    <appender-ref ref="DebugFileAppender" />
  </logger>
  
  <logger name="kernel.dataLog">
    <appender-ref ref="DataLogFileAppender" />
  </logger>

  <!-- 
    Exceptions are logged twice :
     - once as a single line in the server.log
     - once in a seperate file where their stacktrace is exposed 
   -->
  <logger name="kernel.exception">
    <!-- <appender-ref ref="ServerFileAppender" /> -->
    <appender-ref ref="ExceptionFileAppender" />
  </logger>
</log4net>