Skip to content

Commit c79c035

Browse files
author
Jason Dryhurst-Smith
committed
add the logging provider for log4net
1 parent a03695a commit c79c035

File tree

6 files changed

+111
-11
lines changed

6 files changed

+111
-11
lines changed

CorrelatorSharp.Logging.LoggerProvider.Log4Net/Class1.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
1+
<Project Sdk="Microsoft.NET.Sdk">
32
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
3+
<PackageId>CorrelatorSharp.Logging.LoggerProvider.Log4Net</PackageId>
4+
5+
<Version>1.0.0</Version>
6+
7+
<!--Bump the assembly version only on major releases-->
8+
<AssemblyVersion>1.0.0.0</AssemblyVersion>
9+
10+
<AssemblyName>CorrelatorSharp.Logging.LoggerProvider.Log4Net</AssemblyName>
11+
<Description>CorrelatorSharp, a set of tools for adding correlation identifiers for actions performed by users and machine across your applications. Your one stop shop for context-aware logging and diagnostics.</Description>
12+
<Authors>Ivan Zlatev, Jason Dryhurst-Smith</Authors>
13+
<TargetFrameworks>net47;netstandard2.0</TargetFrameworks>
14+
<PackageTags>context;correlation;logging;diagnostics</PackageTags>
15+
<PackageProjectUrl>https://github.com/CorrelatorSharp/CorrelatorSharp</PackageProjectUrl>
16+
<PackageLicenseUrl>https://github.com/CorrelatorSharp/CorrelatorSharp/blob/master/LICENSE.txt</PackageLicenseUrl>
17+
518
</PropertyGroup>
19+
<ItemGroup>
20+
<PackageReference Include="log4net" Version="[2.0.8,3)" />
21+
<PackageReference Include="CorrelatorSharp.Logging.Log4Net" Version="[1.0.0,2)"/>
22+
<PackageReference Include="CorrelatorSharp.Logging.LoggerProvider" Version="[1.0.0,2)"/>
23+
</ItemGroup>
624

725
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Diagnostics.CodeAnalysis;
3+
using log4net.Repository;
4+
using Microsoft.Extensions.Logging;
5+
6+
namespace CorrelatorSharp.Logging.LoggerProvider.Log4Net
7+
{
8+
[ProviderAlias("CorrelatorSharp.Log4Net")]
9+
[ExcludeFromCodeCoverage]
10+
public class Log4NetCorrelatorSharpLoggerProvider : CorrelatorSharpLoggerProvider
11+
{
12+
public Log4NetCorrelatorSharpLoggerProvider(ILoggerRepository repo = null)
13+
: base(new Log4NetScopeProvider())
14+
{
15+
LoggingConfiguration.Current.UseLog4Net(repo);
16+
}
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
3+
namespace CorrelatorSharp.Logging.LoggerProvider.Log4Net
4+
{
5+
public class Log4NetScopeProvider : IScopeProvider
6+
{
7+
public IDisposable BeginScope<TState>(TState state)
8+
{
9+
// TODO - Allow the user to provide some extra form of scope.
10+
return null;
11+
}
12+
13+
public void ErrorBuildingScope(Exception exception)
14+
{
15+
16+
}
17+
}
18+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using CorrelatorSharp.Logging.LoggerProvider.Log4Net;
2+
using log4net.Repository;
3+
using Microsoft.Extensions.DependencyInjection;
4+
using Microsoft.Extensions.Logging;
5+
6+
namespace CorrelatorSharp.Logging
7+
{
8+
public static class ServiceCollectionExtensions
9+
{
10+
public static void UseCorrelatorSharpLog4NetLoggerProvider(this IServiceCollection serviceCollection, ILoggerRepository repo = null)
11+
{
12+
serviceCollection.AddSingleton<ILoggerProvider>(new Log4NetCorrelatorSharpLoggerProvider(repo));
13+
}
14+
}
15+
}

appveyor.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
environment:
2+
package_version: '1.0.0'
3+
assembly_version: '1.0.0.0'
4+
5+
version: '$(package_version)+{build}'
6+
7+
image: Visual Studio 2017
8+
9+
dotnet_csproj:
10+
patch: true
11+
file: '**\*.csproj'
12+
version: '$(package_version)'
13+
assembly_version: '$(assembly_version)'
14+
15+
configuration: Release
16+
17+
before_build: dotnet restore
18+
19+
build:
20+
publish_nuget: true
21+
publish_nuget_symbols: true
22+
verbosity: minimal
23+
24+
deploy:
25+
- provider: GitHub
26+
description: |
27+
* Log4net adapter for the logging provider absraction
28+
on:
29+
appveyor_repo_tag: true
30+
31+
release: v$(package_version)
32+
auth_token:
33+
secure: y4HfARa+GScoSgdsOIb7A3L8TV93/wiPBgJENisycZ6yKwBANmPEe1MesK4IC6rm
34+
35+
- provider: NuGet
36+
api_key:
37+
secure: vZC+uEZj00A+9riSWLXqdnPtGa96W9SQkBy30dS2D5bOUdvteU9vOAP69QLJrY/o
38+
on:
39+
appveyor_repo_tag: true

0 commit comments

Comments
 (0)