MicroKnights.Log4NetAdoNetAppender 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MicroKnights.Log4NetAdoNetAppender --version 1.0.0                
NuGet\Install-Package MicroKnights.Log4NetAdoNetAppender -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MicroKnights.Log4NetAdoNetAppender" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MicroKnights.Log4NetAdoNetAppender --version 1.0.0                
#r "nuget: MicroKnights.Log4NetAdoNetAppender, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MicroKnights.Log4NetAdoNetAppender as a Cake Addin
#addin nuget:?package=MicroKnights.Log4NetAdoNetAppender&version=1.0.0

// Install MicroKnights.Log4NetAdoNetAppender as a Cake Tool
#tool nuget:?package=MicroKnights.Log4NetAdoNetAppender&version=1.0.0                

Log4NetAdoNetAppender

.Net Standard 1.3 AdoNetAppender

A late night fix since it do not exists for .net core for some odd reason. This project will only exists until the official logging.apache.org project is releasing their own AdoNetAppender within the log4net package.

How to setup

You log4net.config AdoNetAppender configuration

<log4net>
  <appender name="AdoNetAppender" type="MicroKnights.Logging.AdoNetAppender, MicroKnights.Log4NetAdoNetAppender">
    <bufferSize value="1" />
    <connectionType value="System.Data.SqlClient.SqlConnection,System.Data,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" />
    <connectionStringName value="log4net" />
    <connectionStringFile value="connectionstrings.json" />
    <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>
        <parameterName value="@message" />
        <dbType value="String" />
        <size value="4000" />
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%message" />
        </layout>
    </parameter>
    <parameter>
        <parameterName value="@exception" />
        <dbType value="String" />
        <size value="2000" />
        <layout type="log4net.Layout.ExceptionLayout" />
    </parameter>
  </appender>

With 2 changes, you are up and running in your .net core project.

First you must change/replace the type and assembly name, from this:

<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">

to this:

<appender name="AdoNetAppender" type="MicroKnights.Logging.AdoNetAppender, MicroKnights.Log4NetAdoNetAppender">

Secondly you must specify the configurationfile where your connectionstrings are defined. A new property in the configuration is added - called ConnectionStringFile. It will then locate the connectionstring by using ConnectionStringName.

NuGet Package

PM> Install-Package MicroKnights.Log4NetAdoNetAppender
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (9)

Showing the top 5 NuGet packages that depend on MicroKnights.Log4NetAdoNetAppender:

Package Downloads
MicroKnights.Log4NetHelper

Set ConnectionString manually, Enable internal Debugging, Show configuration messages

MTD.BM.Common

此模块为MTD系统基础模块,包含多个组件

Carbon.Feature.Logging

Feature to support core Carbon logging technolgies.

NPlatform.Infrastructure

net8.0 版本

Apsiyon

Apsiyon framework is a helpful framework that creates your .Net projects in the simplest way, does cross cutting concerns for you and helps you to write code faster in your projects.

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on MicroKnights.Log4NetAdoNetAppender:

Repository Stars
anjoy8/Blog.Core
💖 ASP.NET Core 8.0 全家桶教程,前后端分离后端接口,vue教程姊妹篇,官方文档:
engindemirog/NetCoreBackend
CodeMazeBlog/CodeMazeGuides
The main repository for all the Code Maze guides
Version Downloads Last updated
2.2.1-alpha.2 28,362 9/13/2021
2.2.1-alpha.1 45,161 9/8/2020
2.2.0 921,507 7/26/2020
2.2.0-alpha2 538 7/20/2020
2.2.0-alpha1 406 7/20/2020
2.1.2 225,708 5/12/2020
2.1.0 21,342 4/1/2020
2.0.1 192,285 11/22/2019
2.0.0 6,044 11/16/2019
1.0.2 276,803 5/2/2018
1.0.1 10,375 2/25/2018
1.0.1-alpha 829 2/25/2018
1.0.0 4,844 2/10/2018