Unable to use basic MS SQL Server Configuration
Closed this issue · 2 comments
Hello; I have been using this NuGet package as it was suggested on a Udemy tutorial I am attending. Following the Apache documentation; I am simply unable to get the basic MS SQL Server appender to work with this NuGet package/extensions.
Can anyone please tell me if they have been able to achieve this with this library? All of the tutorials online use the default Log4Net library and not this one so I have little resources to help with this.
I have really loved this library so thank you! I simply am asking if this is my error or an issue with the extension.
This is a copy of my config file. And, yes, I have been able to get the file appender working just fine.
I have replaced the actual connection string credentials with placeholders.
I thank you all for any and all help with this!
<?xml version="1.0" encoding="utf-8"?>
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="100" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<connectionString value="data source=SERVERNAME, 1433;initial catalog=TABLENAME;integrated security=false;persist security info=True;User ID=USERNAME;Password=PASSWORD" />
<commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" />
<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>
<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>
You need to change what dll is been used for writing to the database. The one you have in the config is looking for a .netFramework 1.1 version
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
You can just change it like this ...
I wanted to use Microsoft.Data.SqlClient
<connectionType value="Microsoft.Data.SqlClient.SqlConnection, Microsoft.Data.SqlClient, Version=3.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5" />
and I added the nuget package
Closing as seems solved. Thank you very much @holytshirt for contributing!