File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using log4net . Appender ;
3
+ using log4net . Core ;
4
+
5
+ namespace Exceptionless . Log4net {
6
+ public class BufferingExceptionlessAppender : BufferingAppenderSkeleton {
7
+ private ExceptionlessClient _client = ExceptionlessClient . Default ;
8
+
9
+ public string ApiKey { get ; set ; }
10
+ public string ServerUrl { get ; set ; }
11
+
12
+ protected override void SendBuffer ( LoggingEvent [ ] events ) {
13
+ foreach ( var e in events ) {
14
+ _client . SubmitFromLogEvent ( e ) ;
15
+ }
16
+ }
17
+
18
+ public override void ActivateOptions ( ) {
19
+ base . ActivateOptions ( ) ;
20
+ if ( ! String . IsNullOrEmpty ( ApiKey ) || ! String . IsNullOrEmpty ( ServerUrl ) )
21
+ _client = new ExceptionlessClient ( config =>
22
+ {
23
+ if ( ! String . IsNullOrEmpty ( ApiKey ) )
24
+ config . ApiKey = ApiKey ;
25
+ if ( ! String . IsNullOrEmpty ( ServerUrl ) )
26
+ config . ServerUrl = ServerUrl ;
27
+ config . UseInMemoryStorage ( ) ;
28
+ } ) ;
29
+ }
30
+
31
+ protected override void Append ( LoggingEvent loggingEvent )
32
+ {
33
+ if ( ! _client . Configuration . IsValid )
34
+ return ;
35
+
36
+ base . Append ( loggingEvent ) ;
37
+ }
38
+ }
39
+ }
Original file line number Diff line number Diff line change 47
47
<Compile Include =" ..\..\GlobalAssemblyInfo.cs" >
48
48
<Link >Properties\GlobalAssemblyInfo.cs</Link >
49
49
</Compile >
50
+ <Compile Include =" BufferingExceptionlessAppender.cs" />
50
51
<Compile Include =" ExceptionlessAppender.cs" />
51
52
<Compile Include =" ExceptionlessClientExtensions.cs" />
52
53
<Compile Include =" Log4netExceptionlessLog.cs" />
You can’t perform that action at this time.
0 commit comments