How-To - ArcFM - Add a Rolling Log File Appender to ArcFM

Version 3

    Solution

     

    ArcFM supports the use of a rolling log file as an output option for the existing log4net error reporting used by all ArcFM applications. This document explains how to add a rolling log file appender.

     

    Locate the config file for the application you wish to modify. Some common options are:

     

    ApplicationLog File
    ArcFM DesktopC:\Program Files (x86)ArcGIS\Desktop10.2\bin\miner.log4net.config
    Replication Client/ServerC:\Program Files (x86)\Miner and Miner\ArcFM Solution\Bin\Miner.Replication.log4net.config
    Replication WebC:\inetpub\wwwroot\ArcFMGDBReplicationService\miner.replicationweb.log4net.config
    Geodatabase Manager Services (logging service and rec/post services)C:\Program Files (x86)\Miner and Miner\ArcFM Solution\Bin\GeodatabaseManagerServices.exe.config

     

     

    Within the config file, locate the <log4net> section. Among the appenders listed there, add the following appender type:

     

    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">

          <param name="File" value="E:\Minerservices.log"/>

          <param name="Threshold" value="DEBUG"/>

          <param name="AppendToFile" value="true"/>

          <param name="MaxSizeRollBackups" value="5"/>

          <param name="MaximumFileSize" value="500KB"/>

          <param name="RollingStyle" value="Size"/>

          <param name="StaticLogFileName" value="true"/>

          <layout type="log4net.Layout.PatternLayout">

            <param name="Header" value="&#13;&#10;===== Application Begin =====&#13;&#10;"/>

            <param name="Footer" value="====== Application End ======&#13;&#10;"/>

            <param name="ConversionPattern" value="***************************************************************%newline%date{ISO8601} %-5level %logger%newlineMessage: %message%newlineThread: %thread AppDomain: %appdomain%newlineException: %exceptionProperties: %property%newline"/>

          </layout>

        </appender>

     

    In addition, look for the <root> section below the appender list and add the new appender type:

     

    <appender-ref ref="RollingLogFileAppender"/>

     

    Attached is an example of a GDBM config file modified to include a rolling log file. Note the appender's configuration from lines 27-40 and the appender's inclusion in the active appender types at line 45.

     

    The location of the log file must not require UAC privileges for write access. For example, C:\Program Files (x86), C:\, and C:\Windows require UAC elevation to write to them. Only a handful of administrative tools out of the various ArcFM applications seek UAC privileges on launch. Choosing a restricted location will prevent the creation of the rolling log file without notice. Then, the file will simply not appear and much frustration will ensue. A good option for storing the rolling log file would be the C:\ArcFM folder created by installing the sample data, since this location is not UAC restricted.

     

    Parameters such as the maximum file size (500 KB in the example above), the number of older log files to keep before recycling them (5 in above), or text format can all be modified to meet business needs. Apache has a number of examples on their website at Apache log4net – Apache log4net: Config Examples, but please be aware that the format used in their examples and the format required by the ArcFM .config files are slightly different. For example, a line such as <datePattern value="yyyyMMdd-HHmm" /> would need to be <param name="datePattern" value="yyyyMMdd-HHmm" /> for ArcFM config files.