Skip to content

Commit

Permalink
Merge pull request #10 from kellyelton/master
Browse files Browse the repository at this point in the history
Added BufferingExceptionlessAppender
  • Loading branch information
niemyjski committed Apr 2, 2015
2 parents af30c21 + 966b1a6 commit 8475be8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Source/Platforms/Log4net/BufferingExceptionlessAppender.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using log4net.Appender;
using log4net.Core;

namespace Exceptionless.Log4net {
public class BufferingExceptionlessAppender : BufferingAppenderSkeleton {
private ExceptionlessClient _client = ExceptionlessClient.Default;

public string ApiKey { get; set; }
public string ServerUrl { get; set; }

protected override void SendBuffer(LoggingEvent[] events) {
foreach (var e in events) {
_client.SubmitFromLogEvent(e);
}
}

public override void ActivateOptions() {
base.ActivateOptions();
if (!String.IsNullOrEmpty(ApiKey) || !String.IsNullOrEmpty(ServerUrl))
_client = new ExceptionlessClient(config =>
{
if (!String.IsNullOrEmpty(ApiKey))
config.ApiKey = ApiKey;
if (!String.IsNullOrEmpty(ServerUrl))
config.ServerUrl = ServerUrl;
config.UseInMemoryStorage();
});
}

protected override void Append(LoggingEvent loggingEvent)
{
if (!_client.Configuration.IsValid)
return;

base.Append(loggingEvent);
}
}
}
1 change: 1 addition & 0 deletions Source/Platforms/Log4net/Exceptionless.Log4net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<Compile Include="..\..\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="BufferingExceptionlessAppender.cs" />
<Compile Include="ExceptionlessAppender.cs" />
<Compile Include="ExceptionlessClientExtensions.cs" />
<Compile Include="Log4netExceptionlessLog.cs" />
Expand Down

0 comments on commit 8475be8

Please sign in to comment.