diff --git a/.gitignore b/.gitignore index b3b3401..c0dcbe7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,428 @@ -_ReSharper.* -Build/ -StyleCop.Cache -*.cache -*.user -*.suo -bin/ -obj/ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates +*.env + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ + +[Dd]ebug/x64/ +[Dd]ebugPublic/x64/ +[Rr]elease/x64/ +[Rr]eleases/x64/ +bin/x64/ +obj/x64/ + +[Dd]ebug/x86/ +[Dd]ebugPublic/x86/ +[Rr]elease/x86/ +[Rr]eleases/x86/ +bin/x86/ +obj/x86/ + +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +[Aa][Rr][Mm]64[Ee][Cc]/ +bld/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Build results on 'Bin' directories +**/[Bb]in/* +# Uncomment if you have tasks that rely on *.refresh files to move binaries +# (https://github.com/github/gitignore/pull/3736) +#!**/[Bb]in/*.refresh + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* +*.trx + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Approval Tests result files +*.received.* + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.idb +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +# but not Directory.Build.rsp, as it configures directory-level build defaults +!Directory.Build.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +**/.paket/paket.exe +paket-files/ + +# FAKE - F# Make +**/.fake/ + +# CodeRush personal settings +**/.cr/personal + +# Python Tools for Visual Studio (PTVS) +**/__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +#tools/** +#!tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog +MSBuild_Logs/ + +# AWS SAM Build and Temporary Artifacts folder +.aws-sam + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +**/.mfractor/ + +# Local History for Visual Studio +**/.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +**/.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp diff --git a/Source/Sample/Packages.config b/Source/Sample/Packages.config deleted file mode 100644 index e85d7de..0000000 --- a/Source/Sample/Packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Source/Sample/Properties/AssemblyInfo.cs b/Source/Sample/Properties/AssemblyInfo.cs deleted file mode 100644 index 7208cc6..0000000 --- a/Source/Sample/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Sample")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("Sample")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("303337ca-aa8c-42f7-b4f8-f8a670e48965")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Source/Sample/Sample.csproj b/Source/Sample/Sample.csproj index 35b82bb..4054a7e 100644 --- a/Source/Sample/Sample.csproj +++ b/Source/Sample/Sample.csproj @@ -1,73 +1,13 @@ - - + - Debug - x86 - 8.0.30703 - 2.0 - {2F6882D7-7AEC-4180-A1A0-0A1E90B7AEFA} + net481 Exe - Properties - Sample - Sample - v4.0 - 512 - - - x86 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - x86 - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\packages\log4net.2.0.3\lib\net40-full\log4net.dll - True - - - ..\..\packages\NLog.4.0.0\lib\net40\NLog.dll - True - - - - - - - - - - - - - + + - - {6DC26274-8B27-4B4F-8281-F6DB9E51BDEF} - log4net.NLogAppender - + - - \ No newline at end of file diff --git a/Source/Sample/app.config b/Source/Sample/app.config index fcd0c93..3392417 100644 --- a/Source/Sample/app.config +++ b/Source/Sample/app.config @@ -1,3 +1,6 @@ - - - + + + + + + diff --git a/Source/log4net.NLogAppender.Tests/NLogAppenderTest.cs b/Source/log4net.NLogAppender.Tests/NLogAppenderTest.cs new file mode 100644 index 0000000..c6bbea6 --- /dev/null +++ b/Source/log4net.NLogAppender.Tests/NLogAppenderTest.cs @@ -0,0 +1,69 @@ +using NUnit.Framework; +using System; +using System.Linq; + +namespace log4net.Tests +{ + [TestFixture] + public class NLogAppenderTest + { + private const string TestLoggerName = "TestLogger"; + private const string TestMessage = "Test Message"; + + private readonly NLog.Targets.MemoryTarget _memoryTarget = new NLog.Targets.MemoryTarget(); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + NLog.Config.SimpleConfigurator.ConfigureForTargetLogging(_memoryTarget, NLog.LogLevel.Trace); + + log4net.NLogAppender.Initialize(); + + // Enable Trace level logging in Log4Net + var hierarchy = (log4net.Repository.Hierarchy.Hierarchy)log4net.LogManager.GetRepository(); + hierarchy.Root.Level = log4net.Core.Level.Trace; + } + + [SetUp] + public void Setup() + { + _memoryTarget.Logs.Clear(); + } + + [Test] + public void When_LogTrace_Then_Success() + => TestLog( + (log, message) => log.Logger.Log(typeof(NLogAppenderTest), log4net.Core.Level.Trace, message, null), + "TRACE"); + + [Test] + public void When_LogDebug_Then_Success() + => TestLog((log, message) => log.Debug(message), "DEBUG"); + + [Test] + public void When_LogInfo_Then_Success() + => TestLog((log, message) => log.Info(message), "INFO"); + + [Test] + public void When_LogWarn_Then_Success() + => TestLog((log, message) => log.Warn(message), "WARN"); + + [Test] + public void When_LogError_Then_Success() + => TestLog((log, message) => log.Error(message), "ERROR"); + + [Test] + public void When_LogFatal_Then_Success() + => TestLog((log, message) => log.Fatal(message), "FATAL"); + + public void TestLog(Action writeLogMessage, string logLevel) + { + var log = log4net.LogManager.GetLogger(TestLoggerName); + + writeLogMessage.Invoke(log, TestMessage); + + Assert.That(_memoryTarget.Logs.Count, Is.EqualTo(1)); + Assert.That(_memoryTarget.Logs.Single(), Does.Contain($"|{logLevel}|{TestLoggerName}|{TestMessage}")); + } + } +} \ No newline at end of file diff --git a/Source/log4net.NLogAppender.Tests/log4net.NLogAppender.Tests.csproj b/Source/log4net.NLogAppender.Tests/log4net.NLogAppender.Tests.csproj new file mode 100644 index 0000000..29384f1 --- /dev/null +++ b/Source/log4net.NLogAppender.Tests/log4net.NLogAppender.Tests.csproj @@ -0,0 +1,20 @@ + + + + net35;net462;net481;net8.0 + + false + log4net.Tests + + + + + + + + + + + + + diff --git a/Source/log4net.NLogAppender/Packages.config b/Source/log4net.NLogAppender/Packages.config deleted file mode 100644 index 3094f01..0000000 --- a/Source/log4net.NLogAppender/Packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Source/log4net.NLogAppender/Properties/AssemblyInfo.cs b/Source/log4net.NLogAppender/Properties/AssemblyInfo.cs deleted file mode 100644 index 27360a3..0000000 --- a/Source/log4net.NLogAppender/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("log4net.NLogAppender")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("log4net.NLogAppender")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("92507691-57f7-4e23-ab0a-a734e33d3648")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0")] -[assembly: AssemblyFileVersion("2.0.0")] diff --git a/Source/log4net.NLogAppender/log4net.NLogAppender.csproj b/Source/log4net.NLogAppender/log4net.NLogAppender.csproj index b5e6df0..4e515cf 100644 --- a/Source/log4net.NLogAppender/log4net.NLogAppender.csproj +++ b/Source/log4net.NLogAppender/log4net.NLogAppender.csproj @@ -1,65 +1,12 @@ - - + - Debug - x86 - 8.0.30703 - 2.0 - {6DC26274-8B27-4B4F-8281-F6DB9E51BDEF} - Library - Properties + netstandard2.0;net35;net462 + 2.0.0 log4net - log4net.NLogAppender - v3.5 - 512 - - - x86 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - ..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll - True - - - ..\..\packages\NLog.4.0.0\lib\net35\NLog.dll - True - - - - - - - + - + + - - \ No newline at end of file diff --git a/log4net.NLogAppender.nuspec b/log4net.NLogAppender.nuspec index c6968fb..c87d34b 100644 --- a/log4net.NLogAppender.nuspec +++ b/log4net.NLogAppender.nuspec @@ -7,19 +7,19 @@ https://github.com/lanwin/log4net.NLogAppender false An NLog appender for log4net. - - Its a bridge between NLog and log4net. It hands all log4net logging events over to NLog. - So you could use any lib which uses log4net without even using log4net yourself. - - Simply call the following line and you are done: - - NLogAppender.Initialize(); + + Its a bridge between NLog and log4net. It hands all log4net logging events over to NLog. + So you could use any lib which uses log4net without even using log4net yourself. + + Simply call the following line and you are done: + + NLogAppender.Initialize(); en-US logging nlog log4net appender bridge - - + + diff --git a/log4net.NLogAppender.sln b/log4net.NLogAppender.sln index 804ba10..66d47c7 100644 --- a/log4net.NLogAppender.sln +++ b/log4net.NLogAppender.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36408.4 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "log4net.NLogAppender", "Source\log4net.NLogAppender\log4net.NLogAppender.csproj", "{6DC26274-8B27-4B4F-8281-F6DB9E51BDEF}" EndProject @@ -12,22 +12,31 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution log4net.NLogAppender.nuspec = log4net.NLogAppender.nuspec EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "log4net.NLogAppender.Tests", "Source\log4net.NLogAppender.Tests\log4net.NLogAppender.Tests.csproj", "{35BA08F9-D380-6F07-A421-C4923C55EE71}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6DC26274-8B27-4B4F-8281-F6DB9E51BDEF}.Debug|x86.ActiveCfg = Debug|x86 - {6DC26274-8B27-4B4F-8281-F6DB9E51BDEF}.Debug|x86.Build.0 = Debug|x86 - {6DC26274-8B27-4B4F-8281-F6DB9E51BDEF}.Release|x86.ActiveCfg = Release|x86 - {6DC26274-8B27-4B4F-8281-F6DB9E51BDEF}.Release|x86.Build.0 = Release|x86 - {2F6882D7-7AEC-4180-A1A0-0A1E90B7AEFA}.Debug|x86.ActiveCfg = Debug|x86 - {2F6882D7-7AEC-4180-A1A0-0A1E90B7AEFA}.Debug|x86.Build.0 = Debug|x86 - {2F6882D7-7AEC-4180-A1A0-0A1E90B7AEFA}.Release|x86.ActiveCfg = Release|x86 - {2F6882D7-7AEC-4180-A1A0-0A1E90B7AEFA}.Release|x86.Build.0 = Release|x86 + {6DC26274-8B27-4B4F-8281-F6DB9E51BDEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6DC26274-8B27-4B4F-8281-F6DB9E51BDEF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6DC26274-8B27-4B4F-8281-F6DB9E51BDEF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6DC26274-8B27-4B4F-8281-F6DB9E51BDEF}.Release|Any CPU.Build.0 = Release|Any CPU + {2F6882D7-7AEC-4180-A1A0-0A1E90B7AEFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F6882D7-7AEC-4180-A1A0-0A1E90B7AEFA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F6882D7-7AEC-4180-A1A0-0A1E90B7AEFA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F6882D7-7AEC-4180-A1A0-0A1E90B7AEFA}.Release|Any CPU.Build.0 = Release|Any CPU + {35BA08F9-D380-6F07-A421-C4923C55EE71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35BA08F9-D380-6F07-A421-C4923C55EE71}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35BA08F9-D380-6F07-A421-C4923C55EE71}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35BA08F9-D380-6F07-A421-C4923C55EE71}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B3497C5D-666F-4A0B-A587-6E09B1E6B881} + EndGlobalSection EndGlobal