0

I can't seem to get my configuration set up correctly. Does anyone have any tips?

Config File :

I added

<section name="log4net" 
         type="log4net.Config.Log4NetConfigurationSectionHandler, log4net">

in the config section.

Added the log4net appender

<log4net>
    <appender name="AdoNetAppender" 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=[myServer];Initial Catalog=Log4Net;Integrated Security=SSPI;"/>
  <commandText value="dbo.TestInsertNoParams @log_date"></commandText>
  <commandType value="StoredProcedure"></commandType>
        <parameter>
            <parameterName value="@log_date" />
            <dbType value="DateTime" />
            <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>
    </appender>    
    <root>
        <level value="ALL" />
        <appender-ref ref="AdoNetAppender" />
    </root>
</log4net>

My front end code is:

    private static log4net.ILog Log { get; set; }
    ILog log = log4net.LogManager.GetLogger(typeof(currentClass));
    log.Info("test");

And the global.asax.cs:

 log4net.Config.XmlConfigurator.Configure();

I can connect to that database fine with other operations, I can run the insert statement manually and it runs fine, but nothing is saving....

SQLUSerK
  • 11
  • 3
  • Welcome to StackOverflow: if you post code, XML or data samples, **please** highlight those lines in the text editor and click on the "code samples" button ( `{ }` ) on the editor toolbar to nicely format and syntax highlight it! – marc_s Feb 03 '17 at 22:20
  • Thank you for the debugging link! So I'm getting closer but still no dice. I can call a stored procedure dbo.TestInsert which works fine. :) But when I try to add a parameter (like a message) it suddenly can't find the stored procedure? – SQLUSerK Feb 03 '17 at 23:46
  • That debug let me figure it out.. I just used the original syntax instead of the stored procedure since I don't know the syntax of log4net – SQLUSerK Feb 04 '17 at 00:06

0 Answers0