ODS / API System & Application Logging Configurations

The Ed-Fi ODS / API uses the Apache log4net framework to assist developers and operations staff log system output at a variety of output levels and to a variety of output targets. The log4net documentation provides an overview of the framework capabilities and options.

Logging settings for the ODS / API itself and the ODS / API Administration portal can be configured separately in each application's respective Web.config file. This page provides example logging configurations for specific scenarios.

Default Release Configuration

This configuration is found in the as-shipped ODS / API source. This configuration routes all log messages at the WARN level or above to a rolling file log. This will log to a single file with up to two backup files, and the space taken by each file will not exceed 20MB. This represents the default configuration for a release build.

<log4net>
  <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="${ProgramData}\Ed-Fi-ODS-API\Log.txt" />
    <appendToFile value="true" />
    <maximumFileSize value="20MB" />
    <maxSizeRollBackups value="2" />
    <rollingStyle value="Size" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
    </layout>
  </appender>
  <root>
    <level value="WARN"/>
    <appender-ref ref="RollingFileAppender" />
  </root>
</log4net>

Default Local Developer Configuration

This routes all logging messages at the INFO level or above to the Trace output (i.e., Console), and also provides a rolling file appender for a stable log file to review. This represents the default configuration for a debug build.

<log4net>
  <appender name="TraceAppender" type="log4net.Appender.TraceAppender">
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
    </layout>
  </appender>
  <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="${ProgramData}\Ed-Fi-ODS-API\Log.txt" />
    <appendToFile value="true" />
    <maximumFileSize value="20MB" />
    <maxSizeRollBackups value="2" />
    <rollingStyle value="Size" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
    </layout>
  </appender>
  <root>
    <level value="INFO"/>
    <appender-ref ref="RollingFileAppender" />
    <appender-ref ref="TraceAppender"/>
  </root>
  <logger name="NHibernate">
    <level value="WARN"/>
  </logger>
</log4net> 

Example Support Configuration

In production, it's often useful to log more activity, e.g., when troubleshooting a difficult-to-reproduce issue. This example configuration routes all logging messages at the DEBUG level or above (i.e., all logging messages) to a rolling file log. This will log a large amount of information and should not be left on after reproducing the issue for the support ticket. It increases the rolling size-per-file value to 100MB to ensure all the data is collected, but reduces the number of backup files to 1. After enabling this configuration, detailed files can be inspected to aid in troubleshooting.

<log4net>
  <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="${ProgramData}\Ed-Fi-ODS-API\Log.txt" />
    <appendToFile value="true" />
    <maximumFileSize value="100MB" />
    <maxSizeRollBackups value="1" />
    <rollingStyle value="Size" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
    </layout>
  </appender>
  <root>
    <level value="DEBUG"/>
    <appender-ref ref="RollingFileAppender" />
  </root>
</log4net>