public void ConfiguredConsoleTargetIsPopulatedToNlog() { _loggingOptions.LogTargets.Add(new LogTarget(LogTargetType.Console, LogLevel.Trace)); LoggingConfiguration nlogConfig = NlogConfigurationFactory.Create(_loggingOptions); var target = nlogConfig.AllTargets.FirstOrDefault(t => t.Name.Equals("async_Console")); target.Should().NotBeNull(); }
public void ConfiguredInfoLogLevelIsPopulatedToNlog() { _loggingOptions.LogTargets.Add(new LogTarget(LogTargetType.Console, LogLevel.Information)); LoggingConfiguration nlogConfig = NlogConfigurationFactory.Create(_loggingOptions); LoggingRule loggingRule = nlogConfig.LoggingRules[0]; loggingRule.Should().NotBeNull(); loggingRule.Levels.FirstOrDefault().Should().Be(NLog.LogLevel.Info); }
public void ConfiguredOffLogLevelIsPromotedToNlog() { _loggingOptions.LogTargets.Add(new LogTarget(LogTargetType.Console, LogLevel.None)); LoggingConfiguration nlogConfig = NlogConfigurationFactory.Create(_loggingOptions); LoggingRule loggingRule = nlogConfig.LoggingRules[0]; loggingRule.Should().NotBeNull(); loggingRule.Levels.Should().BeEmpty(); }
public void ConfiguredAsyncTargetIsAddedToNlog() { _loggingOptions.LogTargets.Add(new LogTarget(LogTargetType.Console, LogLevel.Information) { Async = true }); LoggingConfiguration nlogConfig = NlogConfigurationFactory.Create(_loggingOptions); Target target = nlogConfig.AllTargets.FirstOrDefault(); target.Should().NotBeNull(); target.Name.Should().Be($"async_{LogTargetType.Console}"); var asyncTarget = (AsyncTargetWrapper)target; asyncTarget.WrappedTarget.Name.Should().Be(LogTargetType.Console.ToString()); }
/// <summary> /// Configures the <see cref="ILoggerFactory"/> to use the AXOOM logging configuration. /// </summary> /// <param name="loggerFactory">The logger factory to configure.</param> /// <param name="loggingOptions">The logging configuration.</param> public static ILoggerFactory UseAxoomLogging(this ILoggerFactory loggerFactory, LoggingOptions loggingOptions) { LayoutRenderer.Register <SysLogLevelLayoutRenderer>("sysloglevel"); LayoutRenderer.Register <UnixTimeLayoutRenderer>("unixtime"); loggerFactory .WithFilter(new FilterLoggerSettings { Switches = loggingOptions.Filter }) .AddNLog(); LogManager.AddHiddenAssembly(typeof(LoggerFactoryExtensions).GetTypeInfo().Assembly); LogManager.Configuration = NlogConfigurationFactory.Create(loggingOptions); LogManager.Configuration.Reload(); LogManager.ReconfigExistingLoggers(); return(loggerFactory); }