File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
src/Serilog.Sinks.Exceptionless/Sinks/Exceptionless Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
3+ using System . Linq ;
34using Exceptionless ;
45using Exceptionless . Logging ;
56using Serilog . Core ;
@@ -36,6 +37,24 @@ internal static string GetSource(this LogEvent log) {
3637 return null ;
3738 }
3839
40+ internal static string [ ] GetTags ( this LogEvent log )
41+ {
42+ if ( log . Properties . TryGetValue ( "Tags" , out LogEventPropertyValue value ) )
43+ {
44+ var propertyCollection = value . FlattenProperties ( ) as List < object > ;
45+ if ( propertyCollection == null ) return Array . Empty < string > ( ) ;
46+
47+ List < string > tags = new List < string > ( ) ;
48+ foreach ( var item in propertyCollection )
49+ {
50+ tags . Add ( item . ToString ( ) ) ;
51+ }
52+
53+ return tags . ToArray ( ) ;
54+ }
55+ return Array . Empty < string > ( ) ;
56+ }
57+
3958 internal static LogLevel GetLevel ( this LogEventLevel log )
4059 {
4160 switch ( log )
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ public void Emit(LogEvent logEvent) {
108108 if ( logEvent . Level . GetLevel ( ) < minLogLevel )
109109 return ;
110110
111- var builder = _client . CreateFromLogEvent ( logEvent ) . AddTags ( _defaultTags ) ;
111+ var builder = _client . CreateFromLogEvent ( logEvent ) . AddTags ( _defaultTags ) . AddTags ( logEvent . GetTags ( ) ) ;
112112
113113 if ( _includeProperties ) {
114114 foreach ( var prop in logEvent . Properties )
You can’t perform that action at this time.
0 commit comments