Log4net
  1. Log4net
  2. LOG4NET-94

Incorrect config file for ..\examples\net\1.0\Tutorials\ConsoleApp

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.2.9, 1.2.10
    • Fix Version/s: 1.2.11
    • Component/s: Examples
    • Labels:
      None
    • Environment:
      Win2000/VS2005

      Description

      The app.config file has some errors in it...

      Line 39

      is...
      <sppendToFile value="true" />

      should be...
      <appendToFile value="true" />

      Line 43

      is...
      <geader value="[Header] " />

      should be...
      <header value="[Header] " />

      Line 87

      is...
      <commandText" value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)" />

      should be...
      <commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)" />

      Line 94

      is...
      </param>

      should be...
      </layout>

      – Jeff Hegedus: Corrected xml below —

      <?xml version="1.0" encoding="utf-8" ?>
      <!--
      .NET application configuration file
      This file must have the exact same name as your application with .config appended to it.

      For example if your application is ConsoleApp.exe then the config file must be ConsoleApp.exe.config.
      It must also be in the same directory as the application.
      -->
      <configuration>
      <!-- Register a section handler for the log4net section -->
      <configSections>
      <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
      </configSections>
      <appSettings>
      <!-- To enable internal log4net logging specify the following appSettings key -->
      <!-- <add key="log4net.Internal.Debug" value="true"/> -->
      </appSettings>
      <!-- This section contains the log4net configuration settings -->
      <log4net>
      <!-- Define some output appenders -->
      <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="rolling-log.txt" />
      <appendToFile value="true" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="100" />
      <rollingStyle value="Size" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
      <header value="[Header] " />
      <footer value="[Footer] " />
      <conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
      </layout>
      </appender>
      <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
      <file value="log-file.txt" />
      <!-- Example using environment variables in params -->
      <!-- <file value="$

      {TMP}

      \log-file.txt" /> -->
      <appendToFile value="true" />
      <!-- An alternate output encoding can be specified -->
      <!-- <encoding value="unicodeFFFE" /> -->
      <layout type="log4net.Layout.PatternLayout">
      <header value="[Header] " />
      <footer value="[Footer] " />
      <conversionPattern value="%date [%thread] %-5level %logger [%ndc] <%property

      {auth}> - %message%newline" />
      </layout>
      <!-- Alternate layout using XML
      <layout type="log4net.Layout.XMLLayout" /> -->
      </appender>
      <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%ndc] <%property{auth}

      > - %message%newline" />
      </layout>
      </appender>
      <appender name="NetSendAppender" type="log4net.Appender.NetSendAppender">
      <threshold value="ERROR" />
      <server value="IN27WS024728" />
      <recipient value="jhegedus2" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
      </layout>
      </appender>
      <!-- Example of how to configure the AdoNetAppender
      <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender" >
      <connectionString value="Driver=

      {Microsoft Access Driver (*.mdb)}

      ;DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES ('%date','%thread','%level','%logger','%message')" />
      </layout>
      </appender>
      -->
      <!--
      <appender name="A" type="log4net.Appender.ForwardingAppender" >
      <threshold value="WARN"/>
      <appender-ref ref="ConsoleAppender" />
      </appender>
      <appender name="B" type="log4net.Appender.ForwardingAppender" >
      <filter type="log4net.Filter.LevelRangeFilter">
      <levelMin value="DEBUG"/>
      <levelMax value="INFO"/>
      </filter>
      <appender-ref ref="ConsoleAppender" />
      </appender>
      -->
      <!-- Example of how to configure the AdoNetAppender to connect to MS Access -->
      <appender name="ADONetAppender_Access" type="log4net.Appender.AdoNetAppender">
      <connectionString value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;" />
      <commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)" />
      <parameter>
      <parameterName value="@log_date" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="@thread" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%thread" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="@log_level" />
      <dbType value="String" />
      <size value="50" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%level" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="@logger" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%logger" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="@message" />
      <dbType value="String" />
      <size value="1024" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%message" />
      </layout>
      </parameter>
      </appender>
      <!-- Example of how to configure the AdoNetAppender to connect to MS SQL Server -->
      <appender name="ADONetAppender_SqlServer" type="log4net.Appender.AdoNetAppender">
      <bufferSize value="1" />
      <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <connectionString value="data source=SQLSVR;initial catalog=test_log4net;integrated security=false;persist security info=True;User ID=sa;Password=sa" />
      <commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)" />
      <parameter>
      <parameterName value="@log_date" />
      <dbType value="DateTime" />
      <!--
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date

      {yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}

      " />
      </layout>
      -->
      <layout type="log4net.Layout.RawTimeStampLayout" />
      </parameter>
      <parameter>
      <parameterName value="@thread" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%thread" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="@log_level" />
      <dbType value="String" />
      <size value="50" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%level" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="@logger" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%logger" />
      </layout>
      </parameter>
      <parameter>
      <parameterName value="@message" />
      <dbType value="String" />
      <size value="4000" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%message" />
      </layout>
      </parameter>
      </appender>
      <!-- Setup the root category, add the appenders and set the default level -->
      <root>
      <level value="WARN" />
      <appender-ref ref="LogFileAppender" />
      <appender-ref ref="ConsoleAppender" />
      <!-- <appender-ref ref="ADONetAppender_SqlServer" /> -->
      <appender-ref ref="NetSendAppender" />
      <!-- <appender-ref ref="A" /> -->
      </root>
      <!-- Specify the level for some specific categories -->
      <logger name="ConsoleApp.LoggingExample">
      <!-- <appender-ref ref="B" /> -->
      <level value="ALL" />
      <appender-ref ref="RollingLogFileAppender" />
      </logger>
      </log4net>
      </configuration>

        Activity

        Hide
        Ron Grabowski added a comment -

        Fixed in 463334: Corrected typos in example applications' App.config files.

        Show
        Ron Grabowski added a comment - Fixed in 463334: Corrected typos in example applications' App.config files.

          People

          • Assignee:
            Ron Grabowski
            Reporter:
            Jeff Hegedus
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development