Deleted unnecessary files
Not compiling
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
@@ -24,11 +22,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MessageBox.Avalonia" Version="2.1.0" />
|
||||
<PackageReference Include="MessageBox.Avalonia" Version="3.3.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Resources\Avalonia.Resources\Avalonia.Resources.vbproj" />
|
||||
<ProjectReference Include="..\..\Background Services\RandomLogging.Service\RandomLogging.Service.csproj" />
|
||||
<ProjectReference Include="..\..\Controls\LogViewer.Avalonia\LogViewer.Avalonia.csproj" />
|
||||
<ProjectReference Include="..\..\Core\MsLogger.Core\MsLogger.Core.csproj" />
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
@@ -25,11 +23,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Resources\Avalonia.Resources\Avalonia.Resources.vbproj" />
|
||||
<ProjectReference Include="..\..\Background Services\RandomLogging.Service\RandomLogging.Service.csproj" />
|
||||
<ProjectReference Include="..\..\Controls\LogViewer.Avalonia\LogViewer.Avalonia.csproj" />
|
||||
<ProjectReference Include="..\..\Core\Common.Core\Common.Core.csproj" />
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
@@ -24,23 +22,22 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.2" />
|
||||
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2" />
|
||||
<PackageReference Include="MessageBox.Avalonia" Version="2.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.5" />
|
||||
<PackageReference Include="Serilog" Version="4.3.1" />
|
||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" />
|
||||
<PackageReference Include="Serilog.Enrichers.Process" Version="3.0.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Thread" Version="4.0.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="10.0.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="10.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="10.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
|
||||
<PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="9.0.0" />
|
||||
<PackageReference Include="MessageBox.Avalonia" Version="3.3.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Resources\Avalonia.Resources\Avalonia.Resources.vbproj" />
|
||||
<ProjectReference Include="..\..\Background Services\RandomLogging.Service\RandomLogging.Service.csproj" />
|
||||
<ProjectReference Include="..\..\Controls\LogViewer.Avalonia\LogViewer.Avalonia.csproj" />
|
||||
<ProjectReference Include="..\..\Core\Common.Core\Common.Core.csproj" />
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
@@ -24,22 +22,21 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.2" />
|
||||
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.5" />
|
||||
<PackageReference Include="Serilog" Version="4.3.1" />
|
||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" />
|
||||
<PackageReference Include="Serilog.Enrichers.Process" Version="3.0.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Thread" Version="4.0.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="10.0.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="10.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="10.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
|
||||
<PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\Resources\Avalonia.Resources\Avalonia.Resources.vbproj" />
|
||||
<ProjectReference Include="..\..\Background Services\RandomLogging.Service\RandomLogging.Service.csproj" />
|
||||
<ProjectReference Include="..\..\Controls\LogViewer.Avalonia\LogViewer.Avalonia.csproj" />
|
||||
<ProjectReference Include="..\..\Core\Common.Core\Common.Core.csproj" />
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="0.10.18" />
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="0.10.18" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
|
||||
<PackageReference Include="Avalonia" Version="11.3.13" />
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.13" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.13" />
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.18" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.13" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.2" />
|
||||
<PackageReference Include="XamlNameReferenceGenerator" Version="1.6.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="10.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
<PackageReference Include="Serilog" Version="4.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+1
-86
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 18
|
||||
VisualStudioVersion = 18.4.11626.88 stable
|
||||
VisualStudioVersion = 18.4.11626.88
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{A3BEB004-4DF7-4281-9A08-8A7BCD4E3CC9}"
|
||||
EndProject
|
||||
@@ -13,18 +13,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Apps", "Apps", "{42E99803-0
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Controls", "Controls", "{E589E611-C328-4D4F-817D-A91D5A1019FB}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfLoggingDI", "CSharp\Applications\WpfLoggingDI\WpfLoggingDI.csproj", "{9FF3C1CB-C95B-4660-8DD7-9B367824B67C}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Background Services", "Background Services", "{0CDEA51D-46FE-4767-BA2E-8F14582A926D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsLoggingDI", "CSharp\Applications\WinFormsLoggingDI\WinFormsLoggingDI.csproj", "{82EA3F1F-8267-4920-AD4B-BA7087BBD5DA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsLoggingNoDI", "CSharp\Applications\WinFormsLoggingNoDI\WinFormsLoggingNoDI.csproj", "{E17466C3-8CC2-43EA-81C7-85F7EB1A7BAB}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common.Core", "CSharp\Core\Common.Core\Common.Core.csproj", "{1688A0C1-1AE6-49F6-972E-C419E2A3B58F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfLoggingNoDI", "CSharp\Applications\WpfLoggingNoDI\WpfLoggingNoDI.csproj", "{622A3C25-28FD-484A-9CA5-E468CE926673}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{006FDAED-6319-4976-B8BA-8D94E4574139}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
LICENSE = LICENSE
|
||||
@@ -41,12 +33,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MsLogger", "MsLogger", "{86
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Serilog", "Serilog", "{578FF757-F837-4C23-B2CA-3CF8B016F6A9}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfSerilogDI", "CSharp\Applications\WpfSerilogDI\WpfSerilogDI.csproj", "{59A05E46-AB33-4F81-BDF6-3E8C3A1F5D5C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.LogView.Core", "CSharp\Core\Serilog.Sinks.LogView.Core\Serilog.Sinks.LogView.Core.csproj", "{69763AFC-6182-402D-9418-6A48404C89A0}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfSerilogNoDI", "CSharp\Applications\WpfSerilogNoDI\WpfSerilogNoDI.csproj", "{E666F716-F9BD-4630-8610-D41E965B28BA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaLoggingDI", "CSharp\Applications\AvaloniaLoggingDI\AvaloniaLoggingDI.csproj", "{EA97953E-1223-40D5-A568-8932FDC3105E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogViewer.Avalonia", "CSharp\Controls\LogViewer.Avalonia\LogViewer.Avalonia.csproj", "{C34C889C-4EB3-45F6-83DE-70252D1D67D5}"
|
||||
@@ -55,24 +43,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaSerilogDI", "CSharp
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaSerilogNoDI", "CSharp\Applications\AvaloniaSerilogNoDI\AvaloniaSerilogNoDI.csproj", "{4E892500-CF59-43A9-9A27-80D8EE028821}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsSerilogDI", "CSharp\Applications\WinFormsSerilogDI\WinFormsSerilogDI.csproj", "{44282198-F1B3-4C63-A52E-D2E6651D298C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsSerilogNoDI", "CSharp\Applications\WinFormsSerilogNoDI\WinFormsSerilogNoDI.csproj", "{4F3E2263-7FDD-4EBF-929D-1013473720BE}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaLoggingNoDI", "CSharp\Applications\AvaloniaLoggingNoDI\AvaloniaLoggingNoDI.csproj", "{85C96F55-572A-4FDF-A028-12D27A48FB4D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3rd Party", "3rd Party", "{A0B29205-19C3-4FF8-B3A0-28E9E9182E86}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Resources", "Resources", "{7CD1D21E-CCCF-4458-B5E5-63ED2081E439}"
|
||||
EndProject
|
||||
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Avalonia.Resources", "Resources\Avalonia.Resources\Avalonia.Resources.vbproj", "{30AB364F-51E4-4255-865D-1D163B5F82BC}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Logging.Log4Net.AspNetCore", "Resources\3rd Party\Microsoft.Extensions.Logging.Log4Net.AspNetCore\Microsoft.Extensions.Logging.Log4Net.AspNetCore.csproj", "{170F33B5-C7C4-4D97-8DB9-DE508E2DFCD0}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Attribute", "Attribute", "{78E23FC2-A337-4FC2-AEBF-CDC517AEA30C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfLoggingAttrDI", "CSharp\Applications\WpfLoggingAttrDI\WpfLoggingAttrDI.csproj", "{06700271-27A1-4236-9AB3-B45CE431FE0C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -87,26 +59,10 @@ Global
|
||||
{34F75D8B-6F15-4DE4-8335-FED83557EB8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{34F75D8B-6F15-4DE4-8335-FED83557EB8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{34F75D8B-6F15-4DE4-8335-FED83557EB8E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9FF3C1CB-C95B-4660-8DD7-9B367824B67C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9FF3C1CB-C95B-4660-8DD7-9B367824B67C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9FF3C1CB-C95B-4660-8DD7-9B367824B67C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9FF3C1CB-C95B-4660-8DD7-9B367824B67C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{82EA3F1F-8267-4920-AD4B-BA7087BBD5DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{82EA3F1F-8267-4920-AD4B-BA7087BBD5DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{82EA3F1F-8267-4920-AD4B-BA7087BBD5DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{82EA3F1F-8267-4920-AD4B-BA7087BBD5DA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E17466C3-8CC2-43EA-81C7-85F7EB1A7BAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E17466C3-8CC2-43EA-81C7-85F7EB1A7BAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E17466C3-8CC2-43EA-81C7-85F7EB1A7BAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E17466C3-8CC2-43EA-81C7-85F7EB1A7BAB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1688A0C1-1AE6-49F6-972E-C419E2A3B58F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1688A0C1-1AE6-49F6-972E-C419E2A3B58F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1688A0C1-1AE6-49F6-972E-C419E2A3B58F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1688A0C1-1AE6-49F6-972E-C419E2A3B58F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{622A3C25-28FD-484A-9CA5-E468CE926673}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{622A3C25-28FD-484A-9CA5-E468CE926673}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{622A3C25-28FD-484A-9CA5-E468CE926673}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{622A3C25-28FD-484A-9CA5-E468CE926673}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{18BA2294-FE64-481F-A86F-F5FD84438B66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{18BA2294-FE64-481F-A86F-F5FD84438B66}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{18BA2294-FE64-481F-A86F-F5FD84438B66}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -115,18 +71,10 @@ Global
|
||||
{0EDAAABD-495D-43A4-BDFB-A0506CAAC07E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0EDAAABD-495D-43A4-BDFB-A0506CAAC07E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0EDAAABD-495D-43A4-BDFB-A0506CAAC07E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{59A05E46-AB33-4F81-BDF6-3E8C3A1F5D5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{59A05E46-AB33-4F81-BDF6-3E8C3A1F5D5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{59A05E46-AB33-4F81-BDF6-3E8C3A1F5D5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{59A05E46-AB33-4F81-BDF6-3E8C3A1F5D5C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{69763AFC-6182-402D-9418-6A48404C89A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{69763AFC-6182-402D-9418-6A48404C89A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{69763AFC-6182-402D-9418-6A48404C89A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{69763AFC-6182-402D-9418-6A48404C89A0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E666F716-F9BD-4630-8610-D41E965B28BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E666F716-F9BD-4630-8610-D41E965B28BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E666F716-F9BD-4630-8610-D41E965B28BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E666F716-F9BD-4630-8610-D41E965B28BA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EA97953E-1223-40D5-A568-8932FDC3105E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EA97953E-1223-40D5-A568-8932FDC3105E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EA97953E-1223-40D5-A568-8932FDC3105E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -143,30 +91,10 @@ Global
|
||||
{4E892500-CF59-43A9-9A27-80D8EE028821}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4E892500-CF59-43A9-9A27-80D8EE028821}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4E892500-CF59-43A9-9A27-80D8EE028821}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{44282198-F1B3-4C63-A52E-D2E6651D298C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{44282198-F1B3-4C63-A52E-D2E6651D298C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{44282198-F1B3-4C63-A52E-D2E6651D298C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{44282198-F1B3-4C63-A52E-D2E6651D298C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4F3E2263-7FDD-4EBF-929D-1013473720BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4F3E2263-7FDD-4EBF-929D-1013473720BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4F3E2263-7FDD-4EBF-929D-1013473720BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4F3E2263-7FDD-4EBF-929D-1013473720BE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{85C96F55-572A-4FDF-A028-12D27A48FB4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{85C96F55-572A-4FDF-A028-12D27A48FB4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{85C96F55-572A-4FDF-A028-12D27A48FB4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{85C96F55-572A-4FDF-A028-12D27A48FB4D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{30AB364F-51E4-4255-865D-1D163B5F82BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{30AB364F-51E4-4255-865D-1D163B5F82BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{30AB364F-51E4-4255-865D-1D163B5F82BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{30AB364F-51E4-4255-865D-1D163B5F82BC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{170F33B5-C7C4-4D97-8DB9-DE508E2DFCD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{170F33B5-C7C4-4D97-8DB9-DE508E2DFCD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{170F33B5-C7C4-4D97-8DB9-DE508E2DFCD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{170F33B5-C7C4-4D97-8DB9-DE508E2DFCD0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{06700271-27A1-4236-9AB3-B45CE431FE0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{06700271-27A1-4236-9AB3-B45CE431FE0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{06700271-27A1-4236-9AB3-B45CE431FE0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{06700271-27A1-4236-9AB3-B45CE431FE0C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -174,31 +102,18 @@ Global
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{BB614345-449F-46AD-BE8C-5E2B7616EDE2} = {A3BEB004-4DF7-4281-9A08-8A7BCD4E3CC9}
|
||||
{34F75D8B-6F15-4DE4-8335-FED83557EB8E} = {A3BEB004-4DF7-4281-9A08-8A7BCD4E3CC9}
|
||||
{9FF3C1CB-C95B-4660-8DD7-9B367824B67C} = {8635B709-1D5A-4445-AC45-F99EE264634F}
|
||||
{82EA3F1F-8267-4920-AD4B-BA7087BBD5DA} = {8635B709-1D5A-4445-AC45-F99EE264634F}
|
||||
{E17466C3-8CC2-43EA-81C7-85F7EB1A7BAB} = {8635B709-1D5A-4445-AC45-F99EE264634F}
|
||||
{1688A0C1-1AE6-49F6-972E-C419E2A3B58F} = {A3BEB004-4DF7-4281-9A08-8A7BCD4E3CC9}
|
||||
{622A3C25-28FD-484A-9CA5-E468CE926673} = {8635B709-1D5A-4445-AC45-F99EE264634F}
|
||||
{18BA2294-FE64-481F-A86F-F5FD84438B66} = {0CDEA51D-46FE-4767-BA2E-8F14582A926D}
|
||||
{0EDAAABD-495D-43A4-BDFB-A0506CAAC07E} = {23CB559B-2361-4ED6-8A26-D1B1C2005D65}
|
||||
{23CB559B-2361-4ED6-8A26-D1B1C2005D65} = {A3BEB004-4DF7-4281-9A08-8A7BCD4E3CC9}
|
||||
{8635B709-1D5A-4445-AC45-F99EE264634F} = {42E99803-0A95-4172-9079-3B8BF8CBDE9F}
|
||||
{578FF757-F837-4C23-B2CA-3CF8B016F6A9} = {42E99803-0A95-4172-9079-3B8BF8CBDE9F}
|
||||
{59A05E46-AB33-4F81-BDF6-3E8C3A1F5D5C} = {578FF757-F837-4C23-B2CA-3CF8B016F6A9}
|
||||
{69763AFC-6182-402D-9418-6A48404C89A0} = {23CB559B-2361-4ED6-8A26-D1B1C2005D65}
|
||||
{E666F716-F9BD-4630-8610-D41E965B28BA} = {578FF757-F837-4C23-B2CA-3CF8B016F6A9}
|
||||
{EA97953E-1223-40D5-A568-8932FDC3105E} = {8635B709-1D5A-4445-AC45-F99EE264634F}
|
||||
{C34C889C-4EB3-45F6-83DE-70252D1D67D5} = {E589E611-C328-4D4F-817D-A91D5A1019FB}
|
||||
{BCB0601D-E042-4949-8172-7A35A619519C} = {578FF757-F837-4C23-B2CA-3CF8B016F6A9}
|
||||
{4E892500-CF59-43A9-9A27-80D8EE028821} = {578FF757-F837-4C23-B2CA-3CF8B016F6A9}
|
||||
{44282198-F1B3-4C63-A52E-D2E6651D298C} = {578FF757-F837-4C23-B2CA-3CF8B016F6A9}
|
||||
{4F3E2263-7FDD-4EBF-929D-1013473720BE} = {578FF757-F837-4C23-B2CA-3CF8B016F6A9}
|
||||
{85C96F55-572A-4FDF-A028-12D27A48FB4D} = {8635B709-1D5A-4445-AC45-F99EE264634F}
|
||||
{A0B29205-19C3-4FF8-B3A0-28E9E9182E86} = {7CD1D21E-CCCF-4458-B5E5-63ED2081E439}
|
||||
{30AB364F-51E4-4255-865D-1D163B5F82BC} = {7CD1D21E-CCCF-4458-B5E5-63ED2081E439}
|
||||
{170F33B5-C7C4-4D97-8DB9-DE508E2DFCD0} = {A0B29205-19C3-4FF8-B3A0-28E9E9182E86}
|
||||
{78E23FC2-A337-4FC2-AEBF-CDC517AEA30C} = {8635B709-1D5A-4445-AC45-F99EE264634F}
|
||||
{06700271-27A1-4236-9AB3-B45CE431FE0C} = {78E23FC2-A337-4FC2-AEBF-CDC517AEA30C}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {D6A9B467-ED50-40DB-9FFB-5BE745F08DDB}
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace log4net.Appender;
|
||||
|
||||
internal interface IAppenderServiceProvider
|
||||
{
|
||||
IServiceProvider ServiceProvider { set; }
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace log4net.Appender;
|
||||
|
||||
public abstract class ServiceAppenderSkeleton : AppenderSkeleton, IAppenderServiceProvider, IDisposable
|
||||
{
|
||||
private IServiceProvider _serviceProvider;
|
||||
IServiceProvider IAppenderServiceProvider.ServiceProvider { set => _serviceProvider = value; }
|
||||
|
||||
protected T ResolveService<T>() where T : class
|
||||
{
|
||||
if (_serviceProvider == null)
|
||||
return default;
|
||||
|
||||
return _serviceProvider.GetService<T>();
|
||||
}
|
||||
|
||||
public void Dispose() => _serviceProvider = null;
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
using log4net.Core;
|
||||
|
||||
namespace Microsoft.Extensions.Logging.Log4Net.AspNetCore.Entities;
|
||||
|
||||
// ref: http://svn.apache.org/viewvc/logging/log4net/trunk/examples/net/2.0/Extensibility/EventIDLogApp/cs/src/
|
||||
public class EventIDLogImpl : LogImpl, IEventIDLog
|
||||
{
|
||||
public EventIDLogImpl(log4net.Core.ILogger logger) : base(logger) { /* skip */ }
|
||||
|
||||
#region Implementation of IEventIDLog
|
||||
|
||||
public void Log(EventId eventId, LoggingEvent loggingEvent)
|
||||
{
|
||||
// is the EventId empty?
|
||||
if (!(eventId.Id == 0 && string.IsNullOrWhiteSpace(eventId.Name)))
|
||||
loggingEvent.Properties[nameof(EventId)] = eventId;
|
||||
|
||||
Logger.Log(loggingEvent);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
using log4net;
|
||||
using log4net.Core;
|
||||
|
||||
namespace Microsoft.Extensions.Logging.Log4Net.AspNetCore.Entities;
|
||||
|
||||
public interface IEventIDLog : ILog
|
||||
{
|
||||
void Log(EventId eventId, LoggingEvent loggingEvent);
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Extensions.Logging.Log4Net.AspNetCore.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a candidate for a log message that should be printed. This candidate will either be accepted or denied by the logger that is trying to print it.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This is a readonly struct to reduce memory pressure, but because it is quite large (definitly larger than the recommended 16 bytes)
|
||||
/// it needs to be passed as a reference (with the in keyword) to make a difference.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// See <see href="https://devblogs.microsoft.com/premier-developer/the-in-modifier-and-the-readonly-structs-in-c/"/> for more information.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <typeparam name="TState">Type of the state that is used to format the error message.</typeparam>
|
||||
public readonly struct MessageCandidate<TState>
|
||||
{
|
||||
public MessageCandidate(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||
{
|
||||
State = state;
|
||||
LogLevel = logLevel;
|
||||
EventId = eventId;
|
||||
Exception = exception;
|
||||
Formatter = formatter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The log level the message should be printed with.
|
||||
/// </summary>
|
||||
public LogLevel LogLevel { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The event id of the message.
|
||||
/// </summary>
|
||||
public EventId EventId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The message state. Can be provided to the formatter to generate the string representation of the error message.
|
||||
/// </summary>
|
||||
public TState State { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Exception that should be printed with the message. Null if the log message has no corrosponding exception.
|
||||
/// </summary>
|
||||
public Exception Exception { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The message formatter. Can be called with the state and exception to generate the string representation of the error message.
|
||||
/// </summary>
|
||||
public Func<TState, Exception, string> Formatter { get; }
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Extensions.Logging.Log4Net.AspNetCore.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to store information of a log4net xml config file node.
|
||||
/// </summary>
|
||||
public class NodeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the x path to find the node to override.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The x path.
|
||||
/// </value>
|
||||
public string XPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the content of the node.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The content of the node.
|
||||
/// </value>
|
||||
public string NodeContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the attributes.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The attributes.
|
||||
/// </value>
|
||||
public Dictionary<string, string> Attributes { get; set; }
|
||||
}
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Microsoft.Extensions.Logging.Log4Net.AspNetCore.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Class with XmlDocument and XDocument extensions.
|
||||
/// </summary>
|
||||
internal static class DocumentExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a XmlDocument object into xDocument.
|
||||
/// </summary>
|
||||
/// <param name="xmlDocument">The XML document.</param>
|
||||
/// <returns>The XmlDocument converted to XDocument</returns>
|
||||
public static XDocument ToXDocument(this XmlDocument xmlDocument)
|
||||
{
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
xmlDocument.Save(memoryStream);
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
return XDocument.Load(memoryStream);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a XDocument object into XmlDocument
|
||||
/// </summary>
|
||||
/// <param name="xDocument">The x document.</param>
|
||||
/// <returns>The XDocument converted to XmlDocument</returns>
|
||||
public static XmlDocument ToXmlDocument(this XDocument xDocument)
|
||||
{
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
xDocument.Save(memoryStream);
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
var xmlDoc = new XmlDocument();
|
||||
xmlDoc.Load(memoryStream);
|
||||
return xmlDoc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.Extensions.Logging.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Log4Net provider extensions.
|
||||
/// </summary>
|
||||
public static class Log4NetProviderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a logger with the name of the given <see cref="TName"/> type.
|
||||
/// </summary>
|
||||
/// <typeparam name="TName">The type of the class to be used as name of the logger.</typeparam>
|
||||
/// <param name="self">An ILoggerProvider instance.</param>
|
||||
/// <returns>An instance of the <see cref="ILogger"/>.</returns>
|
||||
public static ILogger CreateLogger<TName>(this ILoggerProvider self) where TName : class
|
||||
{
|
||||
if (self == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(self));
|
||||
}
|
||||
|
||||
if (!self.GetType().IsAssignableFrom(typeof(Log4NetProvider)))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(self), "The ILoggerProvider should be of type Log4NetProvider.");
|
||||
}
|
||||
|
||||
return self.CreateLogger(typeof(TName).FullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
using log4net;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Extensions.Logging.Log4Net.AspNetCore.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="ILogExtensions"/> class.
|
||||
/// </summary>
|
||||
public static class LogExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Criticals the specified message.
|
||||
/// </summary>
|
||||
/// <param name="log">The log.</param>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="exception">The exception.</param>
|
||||
public static void Critical(this ILog log, object message, Exception exception)
|
||||
=> log.Logger.Log(null, log4net.Core.Level.Critical, message, exception);
|
||||
|
||||
/// <summary>
|
||||
/// Traces the specified message.
|
||||
/// </summary>
|
||||
/// <param name="log">The log.</param>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="exception">The exception.</param>
|
||||
public static void Trace(this ILog log, object message, Exception exception)
|
||||
=> log.Logger.Log(null, log4net.Core.Level.Trace, message, exception);
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
namespace Microsoft.Extensions.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a log level translator between the different logging systems.
|
||||
/// </summary>
|
||||
public interface ILog4NetLogLevelTranslator
|
||||
{
|
||||
/// <summary>
|
||||
/// Translates a <see cref="LogLevel"/> to a log4net <see cref="log4net.Core.Level"/> based on the provided options.
|
||||
/// </summary>
|
||||
/// <param name="logLevel">The log level to translate.</param>
|
||||
/// <param name="options">The log4net provider options influencing the translation.</param>
|
||||
/// <returns>The corresponding log level for log4net.</returns>
|
||||
log4net.Core.Level TranslateLogLevel(LogLevel logLevel, Log4NetProviderOptions options);
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
using log4net.Core;
|
||||
using Microsoft.Extensions.Logging.Log4Net.AspNetCore.Entities;
|
||||
|
||||
namespace Microsoft.Extensions.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a factory that creates the log4net <see cref="log4net.Core.LoggingEvent"/> from a <see cref="MessageCandidate{TState}"/>.
|
||||
/// </summary>
|
||||
public interface ILog4NetLoggingEventFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Create the <see cref="log4net.Core.LoggingEvent"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="TState">Type of the state object that is used to format the log message.</typeparam>
|
||||
/// <param name="messageCandidate">The message information that should be logged.</param>
|
||||
/// <param name="logger">The logger the event is created for.</param>
|
||||
/// <param name="options">The options of the log4net logging provider.</param>
|
||||
/// <returns>A <see cref="log4net.Core.LoggingEvent"/> that is ready to be logged with the provided logger or null if the candidate should be dropped.</returns>
|
||||
LoggingEvent CreateLoggingEvent<TState>(
|
||||
in MessageCandidate<TState> messageCandidate,
|
||||
log4net.Core.ILogger logger,
|
||||
Log4NetProviderOptions options,
|
||||
IExternalScopeProvider scopeProvider);
|
||||
}
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-100
@@ -1,100 +0,0 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
|
||||
namespace Microsoft.Extensions.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// The log4net extensions class.
|
||||
/// </summary>
|
||||
public static class Log4NetExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds the log4net.
|
||||
/// </summary>
|
||||
/// <param name="factory">The factory.</param>
|
||||
/// <returns>The <see cref="ILoggerFactory"/> with added Log4Net provider</returns>
|
||||
public static ILoggerFactory AddLog4Net(this ILoggerFactory factory)
|
||||
=> factory.AddLog4Net(new Log4NetProviderOptions());
|
||||
|
||||
/// <summary>
|
||||
/// Adds the log4net.
|
||||
/// </summary>
|
||||
/// <param name="factory">The factory.</param>
|
||||
/// <param name="log4NetConfigFile">The log4net Config File.</param>
|
||||
/// <returns>The <see cref="ILoggerFactory"/> after adding the log4net provider.</returns>
|
||||
public static ILoggerFactory AddLog4Net(this ILoggerFactory factory, string log4NetConfigFile)
|
||||
=> factory.AddLog4Net(log4NetConfigFile, false);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the log4net logging provider.
|
||||
/// </summary>
|
||||
/// <param name="factory">The factory.</param>
|
||||
/// <param name="log4NetConfigFile">The log4 net configuration file.</param>
|
||||
/// <param name="watch">if set to <c>true</c> [watch].</param>
|
||||
/// <returns>The <see cref="ILoggerFactory"/> after adding the log4net provider.</returns>
|
||||
public static ILoggerFactory AddLog4Net(this ILoggerFactory factory, string log4NetConfigFile, bool watch)
|
||||
=> factory.AddLog4Net(new Log4NetProviderOptions(log4NetConfigFile, watch));
|
||||
|
||||
/// <summary>
|
||||
/// Adds the log4net logging provider.
|
||||
/// </summary>
|
||||
/// <param name="factory">The logger factory.</param>
|
||||
/// <param name="options">The options for log4net provider.</param>
|
||||
/// <returns>The <see cref="ILoggerFactory"/> after adding the log4net provider.</returns>
|
||||
public static ILoggerFactory AddLog4Net(this ILoggerFactory factory, Log4NetProviderOptions options)
|
||||
{
|
||||
factory.AddProvider(new Log4NetProvider(options));
|
||||
return factory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the log4net logging provider.
|
||||
/// </summary>
|
||||
/// <param name="builder">The logging builder instance.</param>
|
||||
/// <returns>The <see ref="ILoggingBuilder" /> passed as parameter with the new provider registered.</returns>
|
||||
public static ILoggingBuilder AddLog4Net(this ILoggingBuilder builder)
|
||||
{
|
||||
var options = new Log4NetProviderOptions();
|
||||
return builder.AddLog4Net(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the log4net logging provider.
|
||||
/// </summary>
|
||||
/// <param name="builder">The logging builder instance.</param>
|
||||
/// <param name="log4NetConfigFile">The log4net Config File.</param>
|
||||
/// <returns>The <see ref="ILoggingBuilder" /> passed as parameter with the new provider registered.</returns>
|
||||
public static ILoggingBuilder AddLog4Net(this ILoggingBuilder builder, string log4NetConfigFile)
|
||||
{
|
||||
var options = new Log4NetProviderOptions(log4NetConfigFile);
|
||||
return builder.AddLog4Net(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the log4net logging provider.
|
||||
/// </summary>
|
||||
/// <param name="builder">The logging builder instance.</param>
|
||||
/// <param name="log4NetConfigFile">The log4net Config File.</param>
|
||||
/// <param name="watch">if set to <c>true</c>, the configuration will be reloaded when the xml configuration file changes.</param>
|
||||
/// <returns>
|
||||
/// The <see ref="ILoggingBuilder" /> passed as parameter with the new provider registered.
|
||||
/// </returns>
|
||||
public static ILoggingBuilder AddLog4Net(this ILoggingBuilder builder, string log4NetConfigFile, bool watch)
|
||||
{
|
||||
var options = new Log4NetProviderOptions(log4NetConfigFile, watch);
|
||||
return builder.AddLog4Net(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the log4net logging provider.
|
||||
/// </summary>
|
||||
/// <param name="builder">The logging builder instance.</param>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <returns>The <see ref="ILoggingBuilder" /> passed as parameter with the new provider registered.</returns>
|
||||
public static ILoggingBuilder AddLog4Net(this ILoggingBuilder builder, Log4NetProviderOptions options)
|
||||
{
|
||||
builder.Services.Replace(ServiceDescriptor.Singleton<ILoggerProvider>(sp => new Log4NetProvider(options, sp)));
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
}
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
using log4net.Core;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Extensions.Logging
|
||||
{
|
||||
/// <inheritdoc cref="ILog4NetLogLevelTranslator"/>
|
||||
public sealed class Log4NetLogLevelTranslator : ILog4NetLogLevelTranslator
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Level TranslateLogLevel(LogLevel logLevel, Log4NetProviderOptions options)
|
||||
{
|
||||
Level log4NetLevel = null;
|
||||
switch (logLevel)
|
||||
{
|
||||
case LogLevel.Critical:
|
||||
string overrideCriticalLevelWith = options.OverrideCriticalLevelWith;
|
||||
log4NetLevel = !string.IsNullOrEmpty(overrideCriticalLevelWith)
|
||||
&& overrideCriticalLevelWith.Equals(LogLevel.Critical.ToString(), StringComparison.OrdinalIgnoreCase)
|
||||
? Level.Critical
|
||||
: Level.Fatal;
|
||||
break;
|
||||
case LogLevel.Debug:
|
||||
log4NetLevel = Level.Debug;
|
||||
break;
|
||||
case LogLevel.Error:
|
||||
log4NetLevel = Level.Error;
|
||||
break;
|
||||
case LogLevel.Information:
|
||||
log4NetLevel = Level.Info;
|
||||
break;
|
||||
case LogLevel.Warning:
|
||||
log4NetLevel = Level.Warn;
|
||||
break;
|
||||
case LogLevel.Trace:
|
||||
log4NetLevel = Level.Trace;
|
||||
break;
|
||||
}
|
||||
|
||||
return log4NetLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
using log4net;
|
||||
using log4net.Core;
|
||||
using Microsoft.Extensions.Logging.Log4Net.AspNetCore.Entities;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Extensions.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// The log4net eventIdLogger class.
|
||||
/// </summary>
|
||||
public class Log4NetLogger : ILogger
|
||||
{
|
||||
private readonly IExternalScopeProvider externalScopeProvider;
|
||||
|
||||
/// <summary>
|
||||
/// The log.
|
||||
/// </summary>
|
||||
private readonly IEventIDLog eventIdLogger;
|
||||
|
||||
/// <summary>
|
||||
/// The provider options.
|
||||
/// </summary>
|
||||
private readonly Log4NetProviderOptions options;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Log4NetLogger"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options">The log4net provider options.</param>
|
||||
public Log4NetLogger(Log4NetProviderOptions options, IExternalScopeProvider externalScopeProvider)
|
||||
{
|
||||
this.options = options ?? throw new ArgumentNullException(nameof(options));
|
||||
this.externalScopeProvider = externalScopeProvider ?? throw new ArgumentNullException(nameof(externalScopeProvider));
|
||||
this.eventIdLogger = new EventIDLogImpl(LogManager.GetLogger(options.LoggerRepository, options.Name).Logger);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
public string Name
|
||||
=> this.eventIdLogger.Logger.Name;
|
||||
|
||||
/// <summary>
|
||||
/// A get-only property for accessing the <see cref="Log4NetProviderOptions"/>
|
||||
/// within the instance.
|
||||
/// </summary>
|
||||
internal Log4NetProviderOptions Options => this.options;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Begins a logical operation scope.
|
||||
/// </summary>
|
||||
/// <typeparam name="TState">The type of the state.</typeparam>
|
||||
/// <param name="state">The identifier for the scope.</param>
|
||||
/// <returns>
|
||||
/// An IDisposable that ends the logical operation scope on dispose.
|
||||
/// </returns>
|
||||
public IDisposable BeginScope<TState>(TState state)
|
||||
=> externalScopeProvider.Push(state);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the logging level is enabled.
|
||||
/// </summary>
|
||||
/// <param name="logLevel">The log level.</param>
|
||||
/// <returns>The <see cref="bool"/> value indicating whether the logging level is enabled.</returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException">Throws when <paramref name="logLevel"/> is outside allowed range.</exception>
|
||||
public bool IsEnabled(LogLevel logLevel)
|
||||
{
|
||||
Level translatedLogLevel = this.options.LogLevelTranslator.TranslateLogLevel(logLevel, Options);
|
||||
if (translatedLogLevel != null)
|
||||
{
|
||||
return this.eventIdLogger.Logger.IsEnabledFor(translatedLogLevel);
|
||||
}
|
||||
|
||||
if (logLevel == LogLevel.None)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new ArgumentOutOfRangeException(nameof(logLevel));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs an exception into the log.
|
||||
/// </summary>
|
||||
/// <param name="logLevel">The log level.</param>
|
||||
/// <param name="eventId">The event Id.</param>
|
||||
/// <param name="state">The state.</param>
|
||||
/// <param name="exception">The exception.</param>
|
||||
/// <param name="formatter">The formatter.</param>
|
||||
/// <typeparam name="TState">The type of the state.</typeparam>
|
||||
/// <exception cref="ArgumentNullException">Throws when the <paramref name="formatter"/> is null.</exception>
|
||||
public void Log<TState>(
|
||||
LogLevel logLevel,
|
||||
EventId eventId,
|
||||
TState state,
|
||||
Exception exception,
|
||||
Func<TState, Exception, string> formatter)
|
||||
{
|
||||
if (!this.IsEnabled(logLevel))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureValidFormatter(formatter);
|
||||
|
||||
var candidate = new MessageCandidate<TState>(logLevel, eventId, state, exception, formatter);
|
||||
|
||||
LoggingEvent loggingEvent = options.LoggingEventFactory.CreateLoggingEvent(in candidate, eventIdLogger.Logger, options, externalScopeProvider);
|
||||
|
||||
if (loggingEvent == null)
|
||||
return;
|
||||
|
||||
this.eventIdLogger.Log(eventId, loggingEvent);
|
||||
}
|
||||
|
||||
private static void EnsureValidFormatter<TState>(Func<TState, Exception, string> formatter)
|
||||
{
|
||||
if (formatter == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(formatter));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-140
@@ -1,140 +0,0 @@
|
||||
using log4net.Core;
|
||||
using Microsoft.Extensions.Logging.Log4Net.AspNetCore.Entities;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Microsoft.Extensions.Logging
|
||||
{
|
||||
/// <inheritdoc cref="ILog4NetLoggingEventFactory"/>
|
||||
public class Log4NetLoggingEventFactory
|
||||
: ILog4NetLoggingEventFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// The default property name for scopes that don't provide their own property name by implementing
|
||||
/// an <see cref="IEnumerable{T}"/> where T is <see cref="KeyValuePair{TKey,TValue}"/> and where TKey
|
||||
/// is <see cref="string"/>.
|
||||
/// </summary>
|
||||
protected const string DefaultScopeProperty = "scope";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public LoggingEvent CreateLoggingEvent<TState>(
|
||||
in MessageCandidate<TState> messageCandidate,
|
||||
log4net.Core.ILogger logger,
|
||||
Log4NetProviderOptions options,
|
||||
IExternalScopeProvider scopeProvider)
|
||||
{
|
||||
Type callerStackBoundaryDeclaringType = typeof(LoggerExtensions);
|
||||
string message = messageCandidate.Formatter(messageCandidate.State, messageCandidate.Exception);
|
||||
Level logLevel = options.LogLevelTranslator.TranslateLogLevel(messageCandidate.LogLevel, options);
|
||||
|
||||
if (logLevel == null || (string.IsNullOrEmpty(message) && messageCandidate.Exception == null))
|
||||
return null;
|
||||
|
||||
var loggingEvent = new LoggingEvent(
|
||||
callerStackBoundaryDeclaringType: callerStackBoundaryDeclaringType,
|
||||
repository: logger.Repository,
|
||||
loggerName: logger.Name,
|
||||
level: logLevel,
|
||||
message: message,
|
||||
exception: messageCandidate.Exception);
|
||||
|
||||
// ref: https://github.com/huorswords/Microsoft.Extensions.Logging.Log4Net.AspNetCore/pull/126/commits/1ad3d429afb4417947863d1bc37231bf7a457f3c
|
||||
|
||||
if (messageCandidate.State is IEnumerable<KeyValuePair<string, object>> formattedLogValues)
|
||||
{
|
||||
foreach (var pair in formattedLogValues)
|
||||
{
|
||||
loggingEvent.Properties[pair.Key] = pair.Value;
|
||||
}
|
||||
}
|
||||
|
||||
EnrichWithScopes(loggingEvent, scopeProvider);
|
||||
|
||||
return loggingEvent;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scopes from the external scope provider and converts them to the properties on the logging event.
|
||||
/// This function will honor the convention that logging scopes can provide their own property name, by implementing
|
||||
/// an <see cref="IEnumerable{T}"/> where T is <see cref="KeyValuePair{TKey,TValue}"/> and where TKey is
|
||||
/// <see cref="string"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default implementation will call Convert.ToString(scope, CultureInfo.InvariantCulture) on all scope objects.
|
||||
/// If you want to do this conversion inside the Log4Net Pipeline, e. g. with a custom layout, you can override this
|
||||
/// method and change the behaviour.
|
||||
/// </remarks>
|
||||
/// <param name="loggingEvent">The <see cref="LoggingEvent"/> the scope information will be added to.</param>
|
||||
/// <param name="scopeProvider">The external provider for the current logging scope.</param>
|
||||
protected virtual void EnrichWithScopes(LoggingEvent loggingEvent, IExternalScopeProvider scopeProvider)
|
||||
{
|
||||
scopeProvider.ForEachScope((scope, @event) =>
|
||||
{
|
||||
// This function will add the scopes in the legacy way they were added before the IExternalScopeProvider was introduced,
|
||||
// to maintain backwards compatibility.
|
||||
// This pretty much means that we are emulating a LogicalThreadContextStack, which is a stack, that allows pushing
|
||||
// strings on to it, which will be concatenated with space as a separator.
|
||||
// See: https://github.com/apache/logging-log4net/blob/47aaf46d5f031ea29d781bac4617bd1bb9446215/src/log4net/Util/LogicalThreadContextStack.cs#L343
|
||||
|
||||
// Because string implements IEnumerable we first need to check for string.
|
||||
if (scope is string)
|
||||
{
|
||||
string previousValue = @event.Properties[DefaultScopeProperty] as string;
|
||||
|
||||
@event.Properties[DefaultScopeProperty] = JoinOldAndNewValue(previousValue, scope.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (scope is IEnumerable col)
|
||||
{
|
||||
foreach (var item in col)
|
||||
{
|
||||
if (item is KeyValuePair<string, string>)
|
||||
{
|
||||
var keyValuePair = (KeyValuePair<string, string>)item;
|
||||
string previousValue = @event.Properties[keyValuePair.Key] as string;
|
||||
@event.Properties[keyValuePair.Key] = JoinOldAndNewValue(previousValue, keyValuePair.Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item is KeyValuePair<string, object>)
|
||||
{
|
||||
var keyValuePair = (KeyValuePair<string, object>)item;
|
||||
string previousValue = @event.Properties[keyValuePair.Key] as string;
|
||||
|
||||
// The current culture should not influence how integers/floats/... are displayed in logging,
|
||||
// so we are using Convert.ToString which will convert IConvertible and IFormattable with
|
||||
// the specified IFormatProvider.
|
||||
string additionalValue = Convert.ToString(keyValuePair.Value, CultureInfo.InvariantCulture);
|
||||
@event.Properties[keyValuePair.Key] = JoinOldAndNewValue(previousValue, additionalValue);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (scope is object)
|
||||
{
|
||||
string previousValue = @event.Properties[DefaultScopeProperty] as string;
|
||||
string additionalValue = Convert.ToString(scope, CultureInfo.InvariantCulture);
|
||||
@event.Properties[DefaultScopeProperty] = JoinOldAndNewValue(previousValue, additionalValue);
|
||||
return;
|
||||
}
|
||||
|
||||
}, loggingEvent);
|
||||
}
|
||||
|
||||
private static string JoinOldAndNewValue(string previousValue, string newValue)
|
||||
{
|
||||
if (string.IsNullOrEmpty(previousValue))
|
||||
{
|
||||
return newValue;
|
||||
}
|
||||
|
||||
return previousValue + " " + newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
-469
@@ -1,469 +0,0 @@
|
||||
using log4net;
|
||||
using log4net.Config;
|
||||
using log4net.Repository;
|
||||
using Microsoft.Extensions.Logging.Log4Net.AspNetCore.Entities;
|
||||
using Microsoft.Extensions.Logging.Log4Net.AspNetCore.Extensions;
|
||||
using Microsoft.Extensions.Logging.Log4Net.AspNetCore.Scope;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using log4net.Appender;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Microsoft.Extensions.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// The log4net provider class.
|
||||
/// </summary>
|
||||
/// <seealso cref="ILoggerProvider" />
|
||||
public class Log4NetProvider : ILoggerProvider, ISupportExternalScope
|
||||
{
|
||||
/// <summary>
|
||||
/// The loggers collection.
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<string, Log4NetLogger> loggers = new ConcurrentDictionary<string, Log4NetLogger>();
|
||||
|
||||
/// <summary>
|
||||
/// Prevents to dispose the object more than single time.
|
||||
/// </summary>
|
||||
private bool disposedValue = false;
|
||||
|
||||
/// <summary>
|
||||
/// The log4net repository.
|
||||
/// </summary>
|
||||
public ILoggerRepository Repository;
|
||||
|
||||
/// <summary>
|
||||
/// The provider options.
|
||||
/// </summary>
|
||||
private Log4NetProviderOptions options;
|
||||
|
||||
/// <summary>
|
||||
/// The external logging scope provider.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Reading the offical logging implementations, it seems like we need to handle the case that this might never be set.
|
||||
/// We handle it with a NullScopeProvider instead of null checks, to make the process of implementing interfaces like
|
||||
/// <see cref="ILog4NetLoggingEventFactory"/> less error prone for consumers.
|
||||
/// </remarks>
|
||||
public IExternalScopeProvider ExternalScopeProvider { get; private set; } = NullScopeProvider.Instance;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Log4NetProvider"/> class.
|
||||
/// </summary>
|
||||
public Log4NetProvider()
|
||||
: this(new Log4NetProviderOptions())
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Log4NetProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="log4NetConfigFileName">The log4NetConfigFile.</param>
|
||||
public Log4NetProvider(string log4NetConfigFileName)
|
||||
: this(new Log4NetProviderOptions(log4NetConfigFileName))
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Log4NetProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <exception cref="ArgumentNullException">options</exception>
|
||||
/// <exception cref="NotSupportedException">Wach cannot be true when you are overwriting config file values with values from configuration section.</exception>
|
||||
public Log4NetProvider(Log4NetProviderOptions options)
|
||||
{
|
||||
this.SetOptionsIfValid(options);
|
||||
|
||||
Assembly loggingAssembly = GetLoggingReferenceAssembly();
|
||||
|
||||
this.CreateLoggerRepository(loggingAssembly)
|
||||
.ConfigureLog4NetLibrary(loggingAssembly);
|
||||
}
|
||||
|
||||
#region IOC implementation
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Log4NetProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="serviceCollection">A reference to the IOC service collection.</param>
|
||||
public Log4NetProvider(IServiceProvider serviceCollection)
|
||||
: this(new Log4NetProviderOptions(), serviceCollection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Log4NetProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="log4NetConfigFileName">The log4NetConfigFile.</param>
|
||||
/// <param name="serviceProvider">A reference to the IOC service collection.</param>
|
||||
public Log4NetProvider(string log4NetConfigFileName, IServiceProvider serviceProvider)
|
||||
: this(new Log4NetProviderOptions(log4NetConfigFileName), serviceProvider)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Log4NetProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <param name="serviceProvider">A reference to the IOC service collection.</param>
|
||||
/// <exception cref="ArgumentNullException">options</exception>
|
||||
/// <exception cref="NotSupportedException">Watch cannot be true when you are overwriting config file values with values from configuration section.</exception>
|
||||
public Log4NetProvider(Log4NetProviderOptions options, IServiceProvider serviceProvider)
|
||||
{
|
||||
this.serviceProvider = serviceProvider;
|
||||
|
||||
this.SetOptionsIfValid(options);
|
||||
|
||||
Assembly loggingAssembly = GetLoggingReferenceAssembly();
|
||||
|
||||
this.CreateLoggerRepository(loggingAssembly)
|
||||
.ConfigureLog4NetLibrary(loggingAssembly);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Holds a reference to the IOC Service Provider
|
||||
/// </summary>
|
||||
private IServiceProvider serviceProvider;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes the instance of the <see cref="Log4NetProvider"/> object.
|
||||
/// </summary>
|
||||
~Log4NetProvider()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the logger.
|
||||
/// </summary>
|
||||
/// <returns>An instance of the <see cref="ILogger"/>.</returns>
|
||||
public ILogger CreateLogger()
|
||||
=> this.CreateLogger(this.options.Name);
|
||||
|
||||
/// <summary>
|
||||
/// Creates the logger.
|
||||
/// </summary>
|
||||
/// <param name="categoryName">The category name.</param>
|
||||
/// <returns>An instance of the <see cref="ILogger"/>.</returns>
|
||||
public ILogger CreateLogger(string categoryName)
|
||||
=> this.loggers.GetOrAdd(categoryName, this.CreateLoggerImplementation);
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases unmanaged and - optionally - managed resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
this.Repository.Shutdown();
|
||||
this.loggers.Clear();
|
||||
|
||||
serviceProvider = null;
|
||||
}
|
||||
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates configuration nodes overriding values if required.
|
||||
/// </summary>
|
||||
/// <param name="configXmlDocument">The configuration file XML document.</param>
|
||||
/// <param name="overridingNodes">The overriding values available</param>
|
||||
/// <returns>An <see cref="XmlDocument"/> within the overriding values replaced.</returns>
|
||||
private static XmlDocument UpdateNodesWithOverridingValues(XmlDocument configXmlDocument, IEnumerable<NodeInfo> overridingNodes)
|
||||
{
|
||||
var additionalConfig = overridingNodes;
|
||||
if (additionalConfig != null)
|
||||
{
|
||||
var configXDoc = configXmlDocument.ToXDocument();
|
||||
foreach (var nodeInfo in additionalConfig)
|
||||
{
|
||||
var node = configXDoc.XPathSelectElement(nodeInfo.XPath);
|
||||
if (node != null)
|
||||
{
|
||||
if (nodeInfo.NodeContent != null)
|
||||
{
|
||||
node.Value = nodeInfo.NodeContent;
|
||||
}
|
||||
|
||||
AddOrUpdateAttributes(node, nodeInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return configXDoc.ToXmlDocument();
|
||||
}
|
||||
|
||||
return configXmlDocument;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds or updates the attributes specified in the node information.
|
||||
/// </summary>
|
||||
/// <param name="node">The node.</param>
|
||||
/// <param name="nodeInfo">The node information.</param>
|
||||
private static void AddOrUpdateAttributes(XElement node, NodeInfo nodeInfo)
|
||||
{
|
||||
if (nodeInfo?.Attributes != null)
|
||||
{
|
||||
foreach (var attribute in nodeInfo.Attributes)
|
||||
{
|
||||
var nodeAttribute = node.Attributes()
|
||||
.FirstOrDefault(a => a.Name.LocalName.Equals(attribute.Key, StringComparison.OrdinalIgnoreCase));
|
||||
if (nodeAttribute != null)
|
||||
{
|
||||
nodeAttribute.Value = attribute.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
node.SetAttributeValue(attribute.Key, attribute.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses log4net config file.
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename.</param>
|
||||
/// <returns>The <see cref="XmlElement"/> with the log4net XML element.</returns>
|
||||
private static XmlDocument ParseLog4NetConfigFile(string filename)
|
||||
{
|
||||
using (FileStream stream = File.OpenRead(filename))
|
||||
{
|
||||
var settings = new XmlReaderSettings
|
||||
{
|
||||
DtdProcessing = DtdProcessing.Prohibit
|
||||
};
|
||||
|
||||
var log4netConfig = new XmlDocument();
|
||||
using (var reader = XmlReader.Create(stream, settings))
|
||||
{
|
||||
log4netConfig.Load(reader);
|
||||
}
|
||||
|
||||
return log4netConfig;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to retrieve the assembly from a "Startup" type found in the stack trace.
|
||||
/// </summary>
|
||||
/// <returns>Null for NetCoreApp 1.1, otherwise, Assembly of Startup type if found in stack trace.</returns>
|
||||
private static Assembly GetCallingAssemblyFromStartup()
|
||||
{
|
||||
var stackTrace = new System.Diagnostics.StackTrace(2);
|
||||
|
||||
for (int i = 0; i < stackTrace.FrameCount; i++)
|
||||
{
|
||||
var frame = stackTrace.GetFrame(i);
|
||||
var type = frame.GetMethod()?.DeclaringType;
|
||||
|
||||
if (string.Equals(type?.Name, "Startup", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return type.Assembly;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the logger implementation.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <returns>The <see cref="Log4NetLogger"/> instance.</returns>
|
||||
private Log4NetLogger CreateLoggerImplementation(string name)
|
||||
{
|
||||
var loggerOptions = new Log4NetProviderOptions
|
||||
{
|
||||
Name = name,
|
||||
LoggerRepository = this.Repository.Name,
|
||||
OverrideCriticalLevelWith = this.options.OverrideCriticalLevelWith,
|
||||
LoggingEventFactory = this.options.LoggingEventFactory ?? new Log4NetLoggingEventFactory(),
|
||||
LogLevelTranslator = this.options.LogLevelTranslator ?? new Log4NetLogLevelTranslator(),
|
||||
};
|
||||
|
||||
return new Log4NetLogger(loggerOptions, ExternalScopeProvider);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current executing assembly considering the target framework.
|
||||
/// </summary>
|
||||
/// <returns>The assembly to be used as the reference logging assembly.</returns>
|
||||
private static Assembly GetLoggingReferenceAssembly()
|
||||
{
|
||||
Assembly assembly = null;
|
||||
|
||||
assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
return assembly ?? GetCallingAssemblyFromStartup();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that provided options combinations are valid, and sets the class field if everything is ok.
|
||||
/// </summary>
|
||||
/// <param name="options">The options to validate.</param>
|
||||
/// <exception cref="NotSupportedException">
|
||||
/// Throws when the Watch option is set and there are properties to override.
|
||||
/// </exception>
|
||||
/// <exception cref="ArgumentNullException">
|
||||
/// Throws when the options parameter is null.
|
||||
/// </exception>
|
||||
private void SetOptionsIfValid(Log4NetProviderOptions options)
|
||||
{
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
if (options.Watch
|
||||
&& options.PropertyOverrides.Any())
|
||||
{
|
||||
throw new NotSupportedException("Wach cannot be true when you are overwriting config file values with values from configuration section.");
|
||||
}
|
||||
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the log4net library using the available configuration data.
|
||||
/// </summary>
|
||||
/// <param name="assembly">The assembly to be used on the configuration.</param>
|
||||
private Log4NetProvider ConfigureLog4NetLibrary(Assembly assembly)
|
||||
{
|
||||
if (this.options.UseWebOrAppConfig)
|
||||
{
|
||||
XmlConfigurator.Configure(this.Repository);
|
||||
return this;
|
||||
}
|
||||
|
||||
if (!this.options.ExternalConfigurationSetup)
|
||||
{
|
||||
string fileNamePath = CreateLog4NetFilePath(assembly);
|
||||
if (this.options.Watch)
|
||||
{
|
||||
XmlConfigurator.ConfigureAndWatch(
|
||||
this.Repository,
|
||||
new FileInfo(fileNamePath));
|
||||
}
|
||||
else
|
||||
{
|
||||
var configXml = ParseLog4NetConfigFile(fileNamePath);
|
||||
if (this.options.PropertyOverrides != null
|
||||
&& this.options.PropertyOverrides.Any())
|
||||
{
|
||||
configXml = UpdateNodesWithOverridingValues(
|
||||
configXml,
|
||||
this.options.PropertyOverrides);
|
||||
}
|
||||
|
||||
XmlConfigurator.Configure(this.Repository, configXml.DocumentElement);
|
||||
}
|
||||
}
|
||||
|
||||
this.InjectServices();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wires up specific adapters for IOC support
|
||||
/// </summary>
|
||||
private void InjectServices()
|
||||
{
|
||||
if (this.Repository is null)
|
||||
return;
|
||||
|
||||
IEnumerable<IAppenderServiceProvider> adapters =
|
||||
this.Repository
|
||||
.GetAppenders()
|
||||
.OfType<IAppenderServiceProvider>();
|
||||
|
||||
foreach (IAppenderServiceProvider adapter in adapters)
|
||||
adapter.ServiceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the log4net.config file path.
|
||||
/// </summary>
|
||||
/// <param name="assembly">The assembly to be used when the configuration indicate to use the current assembly.</param>
|
||||
/// <returns>The full path to the log4net.config file.</returns>
|
||||
private string CreateLog4NetFilePath(Assembly assembly)
|
||||
{
|
||||
string fileNamePath = this.options.Log4NetConfigFileName;
|
||||
if (!Path.IsPathRooted(fileNamePath))
|
||||
{
|
||||
fileNamePath = Path.Combine(AppContext.BaseDirectory, fileNamePath);
|
||||
}
|
||||
|
||||
return Path.GetFullPath(fileNamePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or creates the logger repository using the given assembly.
|
||||
/// </summary>
|
||||
/// <param name="assembly">The assembly to be used to create de repository.</param>
|
||||
private Log4NetProvider CreateLoggerRepository(Assembly assembly)
|
||||
{
|
||||
Type repositoryType = typeof(log4net.Repository.Hierarchy.Hierarchy);
|
||||
|
||||
if (!string.IsNullOrEmpty(this.options.LoggerRepository))
|
||||
{
|
||||
try
|
||||
{
|
||||
this.Repository = LogManager.GetRepository(this.options.LoggerRepository);
|
||||
if (this.options.ExternalConfigurationSetup)
|
||||
{
|
||||
// The logger repository is already configured. We can exit here.
|
||||
return this;
|
||||
}
|
||||
}
|
||||
catch (log4net.Core.LogException)
|
||||
{
|
||||
// The logger repository is not defined outside the extension.
|
||||
this.Repository = null;
|
||||
}
|
||||
|
||||
if (this.Repository == null)
|
||||
{
|
||||
this.Repository =
|
||||
LogManager.CreateRepository(this.options.LoggerRepository, repositoryType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Repository =
|
||||
LogManager.CreateRepository(assembly, repositoryType);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void SetScopeProvider(IExternalScopeProvider scopeProvider)
|
||||
{
|
||||
ExternalScopeProvider = scopeProvider;
|
||||
}
|
||||
}
|
||||
}
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
using Microsoft.Extensions.Logging.Log4Net.AspNetCore.Entities;
|
||||
using Microsoft.Extensions.Logging.Log4Net.AspNetCore.Scope;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Extensions.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// The log4Net provider options.
|
||||
/// </summary>
|
||||
public sealed class Log4NetProviderOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The default log4 net file name
|
||||
/// </summary>
|
||||
private const string DefaultLog4NetFileName = "log4net.config";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Log4NetProviderOptions"/> class.
|
||||
/// </summary>
|
||||
public Log4NetProviderOptions()
|
||||
: this(DefaultLog4NetFileName)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Log4NetProviderOptions"/> class.
|
||||
/// </summary>
|
||||
/// <param name="log4NetConfigFileName">Name of the log4 net configuration file.</param>
|
||||
public Log4NetProviderOptions(string log4NetConfigFileName)
|
||||
: this(log4NetConfigFileName, false)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Log4NetProviderOptions"/> class.
|
||||
/// </summary>
|
||||
/// <param name="log4NetConfigFileName">Name of the log4net configuration file.</param>
|
||||
public Log4NetProviderOptions(string log4NetConfigFileName, bool watch)
|
||||
{
|
||||
this.Log4NetConfigFileName = log4NetConfigFileName;
|
||||
this.Watch = watch;
|
||||
|
||||
this.OverrideCriticalLevelWith = string.Empty;
|
||||
this.Name = string.Empty;
|
||||
this.PropertyOverrides = new List<NodeInfo>();
|
||||
this.ExternalConfigurationSetup = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the log file.
|
||||
/// </summary>
|
||||
public string Log4NetConfigFileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the logger repository.
|
||||
/// </summary>
|
||||
public string LoggerRepository { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the level value that should be used to override default's critical level.
|
||||
/// </summary>
|
||||
public string OverrideCriticalLevelWith { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the property overrides.
|
||||
/// </summary>
|
||||
public List<NodeInfo> PropertyOverrides { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this <see cref="Log4NetProviderOptions"/> is watch.
|
||||
/// </summary>
|
||||
public bool Watch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Let user setup log4net externally
|
||||
/// </summary>
|
||||
public bool ExternalConfigurationSetup { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Let user setup log4net from web.config / app.config.
|
||||
/// </summary>
|
||||
public bool UseWebOrAppConfig { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the factory for the log4net <see cref="log4net.Core.LoggingEvent"/>."/>.
|
||||
/// </summary>
|
||||
public ILog4NetLoggingEventFactory LoggingEventFactory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the translator between the <see cref="LogLevel"/> and the log4net <see cref="log4net.Core.Level"/>.
|
||||
/// </summary>
|
||||
public ILog4NetLogLevelTranslator LogLevelTranslator { get; set; }
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net7.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
|
||||
<PackageId>Microsoft.Extensions.Logging.Log4Net.AspNetCore</PackageId>
|
||||
<Authors>Huor Swords</Authors>
|
||||
<Company></Company>
|
||||
<Product>Microsoft.Extensions.Logging.Log4Net.AspNetCore</Product>
|
||||
<Description>
|
||||
Allows to configure Log4net as Microsoft Extensions Logging handler on any ASP.NET Core application.
|
||||
|
||||
Original code proposal by @anuraj --> https://dotnetthoughts.net/how-to-use-log4net-with-aspnetcore-for-logging/
|
||||
</Description>
|
||||
<Copyright></Copyright>
|
||||
<PackageTags>Microsoft Extensions Logging Log4Net AspNet Core</PackageTags>
|
||||
<RootNamespace>Microsoft.Extensions.Logging.Log4Net.AspNetCore</RootNamespace>
|
||||
<AssemblyName>Microsoft.Extensions.Logging.Log4Net.AspNetCore</AssemblyName>
|
||||
<PackageReleaseNotes>#113 - BeginScope don't work as expected
|
||||
# BREAKING CHANGES
|
||||
* External scope can't be used with the scope factories anymore.
|
||||
* Conversion of numeric values now are managed through CultureInfo.InvariantCulture
|
||||
</PackageReleaseNotes>
|
||||
<PackageProjectUrl>https://github.com/huorswords/Microsoft.Extensions.Logging.Log4Net.AspNetCore</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/huorswords/Microsoft.Extensions.Logging.Log4Net.AspNetCore</RepositoryUrl>
|
||||
<Version>7.1.0</Version>
|
||||
<AssemblyVersion>7.1.0.0</AssemblyVersion>
|
||||
<FileVersion>7.1.0.0</FileVersion>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile Condition="'$(Configuration)' == 'Release'">Microsoft.Extensions.Logging.Log4Net.AspNetCoreKey.snk</AssemblyOriginatorKeyFile>
|
||||
<PackageLicenseExpression></PackageLicenseExpression>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.AzureRepos.Git" Version="1.0.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="log4net" Version="2.0.13" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="LICENSE">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath></PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Extensions.Logging.Log4Net.AspNetCore.Scope
|
||||
{
|
||||
/// <summary>
|
||||
/// A logger scope that does not save any information and does not need to be disposed.
|
||||
/// </summary>
|
||||
internal class NullScope : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton instance that represent every <see cref="NullScope"/>.
|
||||
/// </summary>
|
||||
internal static NullScope Instance { get; } = new NullScope();
|
||||
|
||||
/// <summary>
|
||||
/// Constructor that prevents external instantiation.
|
||||
/// </summary>
|
||||
private NullScope()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
// This is a null scope so we need to dispose nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Extensions.Logging.Log4Net.AspNetCore.Scope
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="IExternalScopeProvider"/> that will not save nor return scopes.
|
||||
/// </summary>
|
||||
internal class NullScopeProvider : IExternalScopeProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton instance that represents every <see cref="NullScopeProvider"/>.
|
||||
/// </summary>
|
||||
internal static NullScopeProvider Instance { get; } = new NullScopeProvider();
|
||||
|
||||
/// <summary>
|
||||
/// Constructor that prevents external instantiation.
|
||||
/// </summary>
|
||||
private NullScopeProvider()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void ForEachScope<TState>(Action<object, TState> callback, TState state)
|
||||
{
|
||||
// All scopes are null scopes so do nothing.
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IDisposable Push(object state)
|
||||
{
|
||||
return NullScope.Instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user