Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 49d9db481e00d20dfbc2b9a2aa0ec7feb8d78819 @lanwin committed Aug 17, 2011
Showing with 178,027 additions and 0 deletions.
  1. +8 −0 .gitignore
  2. +26 −0 NuGet/log4net.NLogAppender.nuspec
  3. BIN Packages/NLog.2.0.0.2000/NLog.2.0.0.2000.nupkg
  4. BIN Packages/NLog.2.0.0.2000/lib/net20/NLog.dll
  5. +14,286 −0 Packages/NLog.2.0.0.2000/lib/net20/NLog.xml
  6. BIN Packages/NLog.2.0.0.2000/lib/net35/NLog.dll
  7. +14,403 −0 Packages/NLog.2.0.0.2000/lib/net35/NLog.xml
  8. BIN Packages/NLog.2.0.0.2000/lib/net40/NLog.dll
  9. +14,353 −0 Packages/NLog.2.0.0.2000/lib/net40/NLog.xml
  10. BIN Packages/NLog.2.0.0.2000/lib/sl2/NLog.dll
  11. +9,119 −0 Packages/NLog.2.0.0.2000/lib/sl2/NLog.xml
  12. BIN Packages/NLog.2.0.0.2000/lib/sl3-wp/NLog.dll
  13. +8,978 −0 Packages/NLog.2.0.0.2000/lib/sl3-wp/NLog.xml
  14. BIN Packages/NLog.2.0.0.2000/lib/sl3/NLog.dll
  15. +9,141 −0 Packages/NLog.2.0.0.2000/lib/sl3/NLog.xml
  16. BIN Packages/NLog.2.0.0.2000/lib/sl4-windowsphone71/NLog.dll
  17. +9,135 −0 Packages/NLog.2.0.0.2000/lib/sl4-windowsphone71/NLog.xml
  18. BIN Packages/NLog.2.0.0.2000/lib/sl4/NLog.dll
  19. +9,542 −0 Packages/NLog.2.0.0.2000/lib/sl4/NLog.xml
  20. +6 −0 Packages/Repositories.config
  21. BIN Packages/log4net.1.2.10/lib/1.0/log4net.dll
  22. +28,655 −0 Packages/log4net.1.2.10/lib/1.0/log4net.xml
  23. BIN Packages/log4net.1.2.10/lib/1.1/log4net.dll
  24. +28,655 −0 Packages/log4net.1.2.10/lib/1.1/log4net.xml
  25. BIN Packages/log4net.1.2.10/lib/2.0/log4net.dll
  26. +28,655 −0 Packages/log4net.1.2.10/lib/2.0/log4net.xml
  27. BIN Packages/log4net.1.2.10/log4net.1.2.10.nupkg
  28. +5 −0 Source/Sample/Packages.config
  29. +41 −0 Source/Sample/Program.cs
  30. +36 −0 Source/Sample/Properties/AssemblyInfo.cs
  31. +69 −0 Source/Sample/Sample.csproj
  32. +79 −0 Source/log4net.NLogAppender/NLogAppender.cs
  33. +5 −0 Source/log4net.NLogAppender/Packages.config
  34. +36 −0 Source/log4net.NLogAppender/Properties/AssemblyInfo.cs
  35. +63 −0 Source/log4net.NLogAppender/log4net.NLogAppender.csproj
  36. BIN Tools/NuGet/NuGet.exe
  37. +1,919 −0 Tools/PSake/en-US/psake.psm1-help.xml
  38. +49 −0 Tools/PSake/psake-config.ps1
  39. +31 −0 Tools/PSake/psake.ps1
  40. +646 −0 Tools/PSake/psake.psm1
  41. +29 −0 default.ps1
  42. +16 −0 log4net.NLogAppender.nuspec
  43. +26 −0 log4net.NLogAppender.sln
  44. +15 −0 psake.cmd
@@ -0,0 +1,8 @@
+_ReSharper.*
+Build/
+StyleCop.Cache
+*.cache
+*.user
+*.suo
+bin/
+obj/
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+ <metadata>
+ <id>log4net.NLogAppender</id>
+ <version>1.0.0</version>
+ <authors>Steve Wagner</authors>
+ <projectUrl>https://github.com/lanwin/log4net.NLogAppender</projectUrl>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <summary>An NLog appender for log4net.</summary>
+ <description>
+ This is a bridge between NLog and log4net. It hands all log4net logging 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();
+ </description>
+ <language>en-US</language>
+ <tags>logging nlog log4net appender bride</tags>
+ <dependencies>
+ <dependency id="NLog" version="2.0" />
+ <dependency id="log4net" version="1.2.0" />
+ </dependencies>
+ </metadata>
+</package>
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<repositories>
+ <repository path="..\packages.config" />
+ <repository path="..\Source\log4net.NLogAppender\packages.config" />
+ <repository path="..\Source\Sample\packages.config" />
+</repositories>
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="log4net" version="1.2.10" />
+ <package id="NLog" version="2.0.0.2000" />
+</packages>
@@ -0,0 +1,41 @@
+using System;
+using NLog.Config;
+using log4net;
+using LogManager = NLog.LogManager;
+
+namespace Sample
+{
+ class Program
+ {
+ static void Main()
+ {
+ SimpleConfigurator.ConfigureForConsoleLogging();
+
+ LogManager.GetLogger("app").Info("works");
+
+ NLogAppender.Initialize();
+
+ LogWithLog4Net();
+
+ Console.ReadLine();
+ }
+
+ static void LogWithLog4Net()
+ {
+ var log = log4net.LogManager.GetLogger("foobar");
+ log.Info("foobar");
+ log.Info("foobar");
+ log.Info("foobar");
+ log.Info("foobar");
+ log.Info("foobar");
+ log.Info("foobar");
+ log.Info("foobar");
+ log.Info("foobar");
+ log.Info("foobar");
+ log.Info("foobar");
+ log.Info("foobar");
+ log.Info("foobar");
+ log.Info("foobar");
+ }
+ }
+}
@@ -0,0 +1,36 @@
+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")]
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{2F6882D7-7AEC-4180-A1A0-0A1E90B7AEFA}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Sample</RootNamespace>
+ <AssemblyName>Sample</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="log4net">
+ <HintPath>..\..\packages\log4net.1.2.10\lib\2.0\log4net.dll</HintPath>
+ </Reference>
+ <Reference Include="NLog">
+ <HintPath>..\..\packages\NLog.2.0.0.2000\lib\net35\NLog.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\log4net.NLogAppender\log4net.NLogAppender.csproj">
+ <Project>{6DC26274-8B27-4B4F-8281-F6DB9E51BDEF}</Project>
+ <Name>log4net.NLogAppender</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using NLog;
+using log4net.Appender;
+using log4net.Config;
+using log4net.Core;
+
+namespace log4net
+{
+ public class NLogAppender : AppenderSkeleton
+ {
+ readonly object _syncRoot = new object();
+ Dictionary<string, Logger> _cache = new Dictionary<string, Logger>();
+
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ var logger = GetLoggerFromCacheSafe(loggingEvent);
+
+ var logEvent = ConvertToNLog(loggingEvent);
+
+ logger.Log(logEvent);
+ }
+
+ Logger GetLoggerFromCacheSafe(LoggingEvent loggingEvent)
+ {
+ Logger logger;
+ if(_cache.TryGetValue(loggingEvent.LoggerName, out logger))
+ return logger;
+
+ lock(_syncRoot)
+ {
+ if(_cache.TryGetValue(loggingEvent.LoggerName, out logger))
+ return logger;
+
+ logger = NLog.LogManager.GetLogger(loggingEvent.LoggerName);
+ _cache = new Dictionary<string, Logger>(_cache) {{loggingEvent.LoggerName, logger}};
+ }
+ return logger;
+ }
+
+ static LogEventInfo ConvertToNLog(LoggingEvent loggingEvent)
+ {
+ return new LogEventInfo
+ {
+ Exception = loggingEvent.ExceptionObject,
+ FormatProvider = null,
+ LoggerName = loggingEvent.LoggerName,
+ Message = Convert.ToString(loggingEvent.MessageObject),
+ Level = ConvertLevel(loggingEvent.Level),
+ TimeStamp = loggingEvent.TimeStamp
+ };
+ }
+
+ static LogLevel ConvertLevel(Level level)
+ {
+ if(level == Level.Info)
+ return LogLevel.Info;
+ if(level == Level.Debug)
+ return LogLevel.Debug;
+ if(level == Level.Error)
+ return LogLevel.Error;
+ if(level == Level.Fatal)
+ return LogLevel.Fatal;
+ if(level == Level.Off)
+ return LogLevel.Off;
+ if(level == Level.Trace)
+ return LogLevel.Trace;
+ if(level == Level.Warn)
+ return LogLevel.Warn;
+
+ throw new NotSupportedException("Level " + level + " is currently not supported.");
+ }
+
+ public static void Initialize()
+ {
+ BasicConfigurator.Configure(new NLogAppender());
+ }
+ }
+}
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="NLog" version="2.0.0.2000" />
+ <package id="log4net" version="1.2.10" />
+</packages>
@@ -0,0 +1,36 @@
+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("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{6DC26274-8B27-4B4F-8281-F6DB9E51BDEF}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>log4net</RootNamespace>
+ <AssemblyName>log4net.NLogAppender</AssemblyName>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject />
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="log4net">
+ <HintPath>..\..\Packages\log4net.1.2.10\lib\2.0\log4net.dll</HintPath>
+ </Reference>
+ <Reference Include="NLog">
+ <HintPath>..\..\Packages\NLog.2.0.0.2000\lib\net20\NLog.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="NLogAppender.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Packages.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
Binary file not shown.
Oops, something went wrong.

0 comments on commit 49d9db4

Please sign in to comment.