diff --git a/src/Platforms/Exceptionless.Extensions.Logging/ExceptionlessLoggerExtensions.cs b/src/Platforms/Exceptionless.Extensions.Logging/ExceptionlessLoggerExtensions.cs index d7bc2841..e7212ae5 100644 --- a/src/Platforms/Exceptionless.Extensions.Logging/ExceptionlessLoggerExtensions.cs +++ b/src/Platforms/Exceptionless.Extensions.Logging/ExceptionlessLoggerExtensions.cs @@ -89,7 +89,7 @@ public static ILoggingBuilder AddExceptionless(this ILoggingBuilder builder, Act /// The . /// If a client is not specified then the will be used. /// The . - [Obsolete("Use ExceptionlessLoggerExtensions.AddExceptionless(ILoggingBuilder,ExceptionlessClient) instead.")] + [Obsolete("Use ExceptionlessLoggerExtensions.AddExceptionless(ILoggingBuilder, ExceptionlessClient) instead.")] public static ILoggerFactory AddExceptionless(this ILoggerFactory factory, ExceptionlessClient client = null) { factory.AddProvider(new ExceptionlessLoggerProvider(client ?? ExceptionlessClient.Default)); return factory; @@ -102,7 +102,7 @@ public static ILoggerFactory AddExceptionless(this ILoggerFactory factory, Excep /// The project api key. /// The Server Url /// The . - [Obsolete("Use ExceptionlessLoggerExtensions.AddExceptionless(ILoggingBuilder,string,string) instead.")] + [Obsolete("Use ExceptionlessLoggerExtensions.AddExceptionless(ILoggingBuilder, string, string) instead.")] public static ILoggerFactory AddExceptionless(this ILoggerFactory factory, string apiKey, string serverUrl = null) { if (String.IsNullOrEmpty(apiKey) && String.IsNullOrEmpty(serverUrl)) return factory.AddExceptionless(); @@ -125,7 +125,7 @@ public static ILoggerFactory AddExceptionless(this ILoggerFactory factory, strin /// The . /// An that applies additional settings and plugins. The project api key must be specified. /// The . - [Obsolete("Use ExceptionlessLoggerExtensions.AddExceptionless(ILoggingBuilder,Action) instead.")] + [Obsolete("Use ExceptionlessLoggerExtensions.AddExceptionless(ILoggingBuilder, Action) instead.")] public static ILoggerFactory AddExceptionless(this ILoggerFactory factory, Action configure) { factory.AddProvider(new ExceptionlessLoggerProvider(configure)); return factory; diff --git a/src/Platforms/Exceptionless.Extensions.Logging/ExceptionlessLoggerProvider.cs b/src/Platforms/Exceptionless.Extensions.Logging/ExceptionlessLoggerProvider.cs index 3b10205e..f3920da4 100644 --- a/src/Platforms/Exceptionless.Extensions.Logging/ExceptionlessLoggerProvider.cs +++ b/src/Platforms/Exceptionless.Extensions.Logging/ExceptionlessLoggerProvider.cs @@ -11,6 +11,9 @@ public class ExceptionlessLoggerProvider : ILoggerProvider { /// public ExceptionlessLoggerProvider(ExceptionlessClient client) { _client = client ?? throw new ArgumentNullException(nameof(client)); + + // Rely on Logging Rules + _client.Configuration.SetDefaultMinLogLevel(Exceptionless.Logging.LogLevel.Trace); } /// @@ -18,8 +21,12 @@ public ExceptionlessLoggerProvider(ExceptionlessClient client) { /// /// An which will be used to configure created loggers. public ExceptionlessLoggerProvider(Action configure) { - configure?.Invoke(ExceptionlessClient.Default.Configuration); _client = ExceptionlessClient.Default; + + // Rely on Logging Rules + _client.Configuration.SetDefaultMinLogLevel(Exceptionless.Logging.LogLevel.Trace); + + configure?.Invoke(_client.Configuration); _shouldDispose = true; } diff --git a/src/Platforms/Exceptionless.Log4net/BufferingExceptionlessAppender.cs b/src/Platforms/Exceptionless.Log4net/BufferingExceptionlessAppender.cs index c95ec8d1..6f359ae7 100644 --- a/src/Platforms/Exceptionless.Log4net/BufferingExceptionlessAppender.cs +++ b/src/Platforms/Exceptionless.Log4net/BufferingExceptionlessAppender.cs @@ -25,7 +25,11 @@ public override void ActivateOptions() { config.ApiKey = ApiKey; if (!String.IsNullOrEmpty(ServerUrl)) config.ServerUrl = ServerUrl; + config.UseInMemoryStorage(); + + // Rely on Logging Rules + config.SetDefaultMinLogLevel(Logging.LogLevel.Trace); }); } diff --git a/src/Platforms/Exceptionless.Log4net/ExceptionlessAppender.cs b/src/Platforms/Exceptionless.Log4net/ExceptionlessAppender.cs index 3088a0c2..9b5d0127 100644 --- a/src/Platforms/Exceptionless.Log4net/ExceptionlessAppender.cs +++ b/src/Platforms/Exceptionless.Log4net/ExceptionlessAppender.cs @@ -18,7 +18,11 @@ public override void ActivateOptions() { config.ApiKey = ApiKey; if (!String.IsNullOrEmpty(ServerUrl)) config.ServerUrl = ServerUrl; + config.UseInMemoryStorage(); + + // Rely on Logging Rules + config.SetDefaultMinLogLevel(Logging.LogLevel.Trace); }); } diff --git a/src/Platforms/Exceptionless.Log4net/ExceptionlessClientExtensions.cs b/src/Platforms/Exceptionless.Log4net/ExceptionlessClientExtensions.cs index 7dc5046a..d0518fba 100644 --- a/src/Platforms/Exceptionless.Log4net/ExceptionlessClientExtensions.cs +++ b/src/Platforms/Exceptionless.Log4net/ExceptionlessClientExtensions.cs @@ -20,7 +20,7 @@ public static EventBuilder CreateFromLogEvent(this ExceptionlessClient client, L builder.SetSource(ev.LoggerName); var props = ev.GetProperties(); - foreach (var key in props.GetKeys().Where(key => !_ignoredEventProperties.Contains(key, StringComparer.OrdinalIgnoreCase))) { + foreach (string key in props.GetKeys().Where(key => !_ignoredEventProperties.Contains(key, StringComparer.OrdinalIgnoreCase))) { string propName = key; if (propName.StartsWith("log4net:")) propName = propName.Substring(8); diff --git a/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs b/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs index cea1d180..1373f375 100644 --- a/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs +++ b/src/Platforms/Exceptionless.NLog/ExceptionlessTarget.cs @@ -28,8 +28,8 @@ public ExceptionlessTarget() { protected override void InitializeTarget() { base.InitializeTarget(); - var apiKey = RenderLogEvent(ApiKey, LogEventInfo.CreateNullEvent()); - var serverUrl = RenderLogEvent(ServerUrl, LogEventInfo.CreateNullEvent()); + string apiKey = RenderLogEvent(ApiKey, LogEventInfo.CreateNullEvent()); + string serverUrl = RenderLogEvent(ServerUrl, LogEventInfo.CreateNullEvent()); if (!String.IsNullOrEmpty(apiKey) || !String.IsNullOrEmpty(serverUrl)) { _client = new ExceptionlessClient(config => { @@ -37,12 +37,17 @@ protected override void InitializeTarget() { config.ApiKey = apiKey; if (!String.IsNullOrEmpty(serverUrl)) config.ServerUrl = serverUrl; + config.UseLogger(new NLogInternalLoggger()); config.UseInMemoryStorage(); - config.SetDefaultMinLogLevel(Logging.LogLevel.Trace); // Rely on NLog Logging Rules + + // Rely on Logging Rules + config.SetDefaultMinLogLevel(Logging.LogLevel.Trace); }); - } - else { + } else { + // Rely on Logging Rules + _client.Configuration.SetDefaultMinLogLevel(Logging.LogLevel.Trace); + if (_client.Configuration.Resolver.HasDefaultRegistration()) { _client.Configuration.UseLogger(new NLogInternalLoggger()); }