Configuring logging libraries to save file logs in the appdata folder.

Log4net

Log4net

Use ${APPDATA}


 <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="${APPDATA}\AppName\log" />
      <appendToFile value="true" />
      <rollingStyle value="Date" />
      <datePattern value="_yyyy.MM.dd.TXT" />
      <staticLogFileName value="false" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %-5level %logger - %message%newline" />
      </layout>
    </appender>

NLog

Use ${specialfolder:folder=ApplicationData}

Post a Comment

Previous Post Next Post