-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1389 from onatm/feature-log4net-adapter
Add log4net logging adapter support
- Loading branch information
Showing
7 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/contrib/loggers/Akka.Logger.log4net/Akka.Logger.log4net.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{DAEC9503-CA75-433F-83DE-E28965D94D56}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Akka.Logger.log4net</RootNamespace> | ||
<AssemblyName>Akka.Logger.log4net</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> | ||
<RestorePackages>true</RestorePackages> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<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|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<DocumentationFile>bin\Release\Akka.Logger.log4net.xml</DocumentationFile> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\..\..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\..\..\SharedAssemblyInfo.cs"> | ||
<Link>Properties\SharedAssemblyInfo.cs</Link> | ||
</Compile> | ||
<Compile Include="Log4NetLogger.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\core\Akka\Akka.csproj"> | ||
<Project>{5deddf90-37f0-48d3-a0b0-a5cbd8a7e377}</Project> | ||
<Name>Akka</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="Akka.Logger.log4net.nuspec" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.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> |
20 changes: 20 additions & 0 deletions
20
src/contrib/loggers/Akka.Logger.log4net/Akka.Logger.log4net.nuspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||
<id>@project@</id> | ||
<title>@project@@title@</title> | ||
<version>@build.number@</version> | ||
<authors>@authors@</authors> | ||
<owners>@authors@</owners> | ||
<description>log4net logging adapter for Akka.NET</description> | ||
<licenseUrl>https://github.com/akkadotnet/akka.net/blob/master/LICENSE</licenseUrl> | ||
<projectUrl>https://github.com/akkadotnet/akka.net</projectUrl> | ||
<iconUrl>http://getakka.net/images/AkkaNetLogo.Normal.png</iconUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<releaseNotes>@releaseNotes@</releaseNotes> | ||
<copyright>@copyright@</copyright> | ||
<tags>@tags@ log4net</tags> | ||
@dependencies@ | ||
@references@ | ||
</metadata> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="Log4NetLogger.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com> | ||
// Copyright (C) 2013-2015 Akka.NET project <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
|
||
using System; | ||
using Akka.Actor; | ||
using Akka.Event; | ||
using log4net; | ||
|
||
namespace Akka.Logger.log4net | ||
{ | ||
/// <summary> | ||
/// This class is used to receive log events and sends them to | ||
/// the configured log4net logger. The following log events are | ||
/// recognized: <see cref="Debug"/>, <see cref="Info"/>, | ||
/// <see cref="Warning"/> and <see cref="Error"/>. | ||
/// </summary> | ||
public class Log4NetLogger : ReceiveActor | ||
{ | ||
private readonly ILoggingAdapter _log = Context.GetLogger(); | ||
|
||
private static void Log(LogEvent logEvent, Action<ILog> logStatement) | ||
{ | ||
var logger = LogManager.GetLogger(logEvent.LogClass.FullName); | ||
logStatement(logger); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Log4NetLogger"/> class. | ||
/// </summary> | ||
public Log4NetLogger() | ||
{ | ||
Receive<Error>(m => Log(m, logger => logger.Error(string.Format("{0}", m.Message), m.Cause))); | ||
Receive<Warning>(m => Log(m, logger => logger.WarnFormat("{0}", m.Message))); | ||
Receive<Info>(m => Log(m, logger => logger.InfoFormat("{0}", m.Message))); | ||
Receive<Debug>(m => Log(m, logger => logger.DebugFormat("{0}", m.Message))); | ||
Receive<InitializeLogger>(m => | ||
{ | ||
_log.Info("log4net started"); | ||
Sender.Tell(new LoggerInitialized()); | ||
}); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/contrib/loggers/Akka.Logger.log4net/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="AssemblyInfo.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com> | ||
// Copyright (C) 2013-2015 Akka.NET project <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
|
||
using System.Reflection; | ||
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("Akka.Logger.log4net")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyProduct("Akka.Logger.log4net")] | ||
[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("96446c5f-f8af-4e23-ae85-bc3eae49c7b2")] | ||
[assembly: log4net.Config.XmlConfigurator] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="log4net" version="2.0.3" targetFramework="net45" /> | ||
</packages> |