File tree 1 file changed +20
-13
lines changed
src/Agent/NewRelic/Agent/Core/Logging
1 file changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -115,19 +115,26 @@ private static LoggerConfiguration ConfigureEventLogSink(this LoggerConfiguratio
115
115
#if NETFRAMEWORK
116
116
const string eventLogName = "Application" ;
117
117
const string eventLogSourceName = "New Relic .NET Agent" ;
118
-
119
- loggerConfiguration
120
- . WriteTo . Logger ( configuration =>
121
- {
122
- configuration
123
- . ExcludeAuditLog ( )
124
- . WriteTo . EventLog (
125
- source : eventLogSourceName ,
126
- logName : eventLogName ,
127
- restrictedToMinimumLevel : LogEventLevel . Warning ,
128
- outputTemplate : "{Level}: {Message}{NewLine}{Exception}"
129
- ) ;
130
- } ) ;
118
+ try
119
+ {
120
+ loggerConfiguration
121
+ . WriteTo . Logger ( configuration =>
122
+ {
123
+ configuration
124
+ . ExcludeAuditLog ( )
125
+ . WriteTo . EventLog (
126
+ source : eventLogSourceName ,
127
+ logName : eventLogName ,
128
+ restrictedToMinimumLevel : LogEventLevel . Warning ,
129
+ outputTemplate : "{Level}: {Message}{NewLine}{Exception}" ,
130
+ manageEventSource : true // Serilog will create the event source if it doesn't exist *and* if the app is running with admin privileges
131
+ ) ;
132
+ } ) ;
133
+ }
134
+ catch
135
+ {
136
+ // ignored -- there's nothing we can do at this point, as EventLog is our "fallback" logger and if it fails, we're out of luck
137
+ }
131
138
#endif
132
139
return loggerConfiguration ;
133
140
}
You can’t perform that action at this time.
0 commit comments