-
-
Notifications
You must be signed in to change notification settings - Fork 142
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 #10 from kellyelton/master
Added BufferingExceptionlessAppender
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
Source/Platforms/Log4net/BufferingExceptionlessAppender.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,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); | ||
} | ||
} | ||
} |
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