Skip to content
adrianluisgonzalez edited this page Oct 19, 2012 · 2 revisions

slf4net is typically configured via the application configuration file using a custom config section. To perform configuration programmatically see this page.

slf4net.log4net

Here is an example using the log4net adapter factory.

There is an optional factory-data element which allows one to specify:

  • configFile: A custom log4net configuration file name. If this is not provided the application file is assumed to contain the log4net configuration.
  • watch: true or false to indicate whether log4net should watch the configuration file for changes.
<configuration>

  <configSections>
    <section name="slf4net" type="slf4net.Configuration.SlfConfigurationSection, slf4net"/>
  </configSections>

  <slf4net>
    <factory type="slf4net.log4net.Log4netLoggerFactory, slf4net.log4net">
      <factory-data>
        <configFile value="log4net.config"/>
        <watch value="true"/>
      </factory-data>
    </factory>
  </slf4net>

</configuration>

slf4net.NLog

Here is an example using the NLog adapter factory.

<configuration>

  <configSections>
    <section name="slf4net" type="slf4net.Configuration.SlfConfigurationSection, slf4net"/>
  </configSections>

  <slf4net>
    <factory type="slf4net.NLog.NLogLoggerFactory, slf4net.NLog" />
  </slf4net>

</configuration>
Clone this wiki locally