public static ILoggerFactory AddNLog(
     this ILoggerFactory factory,
     global::NLog.LogFactory logFactory)
 {
     factory.AddProvider(new NLog.NLogLoggerProvider(logFactory));
     return factory;
 }
 public static ILoggerFactory AddNLog(this ILoggerFactory factory, IConfigurationRoot configuration)
 {
     LogManager.AddHiddenAssembly(typeof (AspNetExtensions).GetTypeInfo().Assembly);
     factory.AddProvider(new NLogLoggerProvider());
     LogManager.Configuration = new XmlLoggingConfiguration(configuration[NLogConfigurationPathKey], true);
     return factory;
 }
 /// <summary>
 /// Adds a console logger that is enabled as defined by the filter function.
 /// </summary>
 /// <param name="factory"></param>
 /// <param name="filter"></param>
 /// <param name="includeScopes">A value which indicates whether log scope information should be displayed
 /// in the output.</param>
 public static ILoggerFactory AddConsole(
     this ILoggerFactory factory,
     Func<string, LogLevel, bool> filter,
     bool includeScopes)
 {
     factory.AddProvider(new ConsoleLoggerProvider(filter, includeScopes));
     return factory;
 }
 public static ILoggerFactory AddDbLogger(
     this ILoggerFactory factory,
     IServiceProvider serviceProvider,
     ILogRepository logRepository)
 {
     factory.AddProvider(new DbLoggerProvider(factory.MinimumLevel, serviceProvider, logRepository));
     return factory;
 }
        /// <summary>
        /// Enable NLog as logging provider in Foundatio.
        /// </summary>
        /// <param name="factory"></param>
        /// <returns></returns>
        public static ILoggerFactory AddNLog(this ILoggerFactory factory) {
            //ignore this
            LogManager.AddHiddenAssembly(typeof(LogFactoryExtensions).GetTypeInfo().Assembly);

            factory.AddProvider(new NLogLoggerProvider());

            return factory;
        }
        /// <summary>
        /// Enable NLog as logging provider in Foundatio.
        /// </summary>
        /// <param name="factory"></param>
        /// <param name="populateAdditionalLogEventInfo">Callback that allows populating additional log event information from the log state and scopes.</param>
        /// <returns></returns>
        public static ILoggerFactory AddNLog(this ILoggerFactory factory, Action<object, object[], LogEventInfo> populateAdditionalLogEventInfo) {
            //ignore this
            LogManager.AddHiddenAssembly(typeof(LogFactoryExtensions).GetTypeInfo().Assembly);

            factory.AddProvider(new NLogLoggerProvider(populateAdditionalLogEventInfo));

            return factory;
        }
        /// <summary>
        /// Add Serilog to the logging pipeline.
        /// </summary>
        /// <param name="factory">The logger factory to configure.</param>
        /// <param name="logger">The Serilog logger; if not supplied, the static <see cref="Serilog.Log"/> will be used.</param>
        /// <returns>The logger factory.</returns>
        public static ILoggerFactory AddSerilog(
            this ILoggerFactory factory,
            Serilog.ILogger logger = null)
        {
            if (factory == null) throw new ArgumentNullException("factory");

            factory.AddProvider(new SerilogLoggerProvider(logger));

            return factory;
        }
        /// <summary>
        /// Adds a memory logger that is enabled as defined by the filter function.
        /// </summary>
        public static ILoggerFactory AddMemory(this ILoggerFactory factory, Func<string, LogLevel, bool> filter, int maxLogCount)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            factory.AddProvider(new MemoryLoggerProvider(filter,maxLogCount));
            return factory;
        }
        /// <summary>
        /// Adds a memory logger that is enabled for <see cref="LogLevel"/>.Information or higher.
        /// </summary>
        public static ILoggerFactory AddMemory(this ILoggerFactory factory, int maxLogCount)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            factory.AddProvider(new MemoryLoggerProvider((category, logLevel) => logLevel >= LogLevel.Information, maxLogCount));
            return factory;
        }
        /// <summary>
        /// Adds a memory logger that is enabled for <see cref="LogLevel"/>s of minLevel or higher.
        /// </summary>
        /// <param name="minLevel">The minimum <see cref="LogLevel"/> to be logged</param>
        public static ILoggerFactory AddMemory(this ILoggerFactory factory, LogLevel minLevel)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            factory.AddProvider(new MemoryLoggerProvider((category, logLevel) => logLevel >= minLevel));
            return factory;
        }
        /// <summary>
        /// Enable NLog
        /// </summary>
        /// <param name="factory"></param>
        /// <returns></returns>
        public static ILoggerFactory AddNLog(this ILoggerFactory factory)
        {
            //ignore this
            LogManager.AddHiddenAssembly(typeof(AspNetExtensions).GetTypeInfo().Assembly);

            using (var provider = new NLogLoggerProvider())
            {
                factory.AddProvider(provider);
            }
            return factory;
        }
        /// <summary>
        /// Enable NLog as logging provider in ASP.NET Core.
        /// </summary>
        /// <param name="factory"></param>
        /// <returns></returns>
        public static ILoggerFactory AddNLog(this ILoggerFactory factory)
        {
            //ignore this
            LogManager.AddHiddenAssembly(Assembly.Load(new AssemblyName("Microsoft.Extensions.Logging")));
            LogManager.AddHiddenAssembly(Assembly.Load(new AssemblyName("Microsoft.Extensions.Logging.Abstractions")));
            LogManager.AddHiddenAssembly(typeof(AspNetExtensions).GetTypeInfo().Assembly);

            using (var provider = new NLogLoggerProvider())
            {
                factory.AddProvider(provider);
            }
            return factory;
        }
        public static ILoggerFactory AddEntityFramework(this ILoggerFactory factory, string nameOrConnectionString, Func<string, LogLevel, bool> filter = null)
        {
            if (factory == null) throw new ArgumentNullException("factory");

            if (string.IsNullOrEmpty(nameOrConnectionString))
            {
                throw new ArgumentNullException("nameOrConnectionString");
            }


            factory.AddProvider(new EntityFrameworkLoggerProvider(nameOrConnectionString, filter));

            return factory;
        }
        public static ILoggerFactory AddEntityFramework(this ILoggerFactory factory, string nameOrConnectionString, IConfiguration configuration)
        {
            if (factory == null) throw new ArgumentNullException("factory");

            if (string.IsNullOrEmpty(nameOrConnectionString))
            {
                throw new ArgumentNullException("nameOrConnectionString");
            }

            var settings = new ConfigurationConsoleLoggerSettings(configuration);
            factory.AddProvider(new EntityFrameworkLoggerProvider(nameOrConnectionString, settings));

            return factory;
        }
        /// <summary>
        /// Adds an event logger that is enabled for <see cref="LogLevel"/>s of minLevel or higher.
        /// </summary>
        /// <param name="factory">The extension method argument.</param>
        /// <param name="settings">The <see cref="EventLogSettings"/>.</param>
        public static ILoggerFactory AddEventLog(
            this ILoggerFactory factory,
            EventLogSettings settings)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            factory.AddProvider(new EventLogLoggerProvider(settings));
            return factory;
        }
        public static ILoggerFactory AddTraceSource(
            this ILoggerFactory factory,
            SourceSwitch sourceSwitch,
            TraceListener listener)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            if (sourceSwitch == null)
            {
                throw new ArgumentNullException(nameof(sourceSwitch));
            }

            if (listener == null)
            {
                throw new ArgumentNullException(nameof(listener));
            }

            factory.AddProvider(new TraceSourceLoggerProvider(sourceSwitch, listener));

            return factory;
        }
        public static ILoggerFactory AddMyLogger(this ILoggerFactory loggerFactory, string basePath)
        {
            loggerFactory.AddProvider(new MyLoggerProvider(basePath));

            return loggerFactory;
        }
Example #18
0
 public static void AddLog4Net(this ILoggerFactory loggerFactory, Func<string, LogLevel, bool> filter)
 {
     loggerFactory.AddProvider(new Log4NetProvider(filter));
 }
Example #19
0
 private static ILoggerFactory AddSimpleConsole(this ILoggerFactory factory)
 {
     factory.AddProvider(new SimpleConsoleLoggerProvider());
     return factory;
 }
 public static void AddTraceLogger( this ILoggerFactory factory )
 {
     factory.AddProvider( new TraceLogProvider() );
 }
 public static void AddTraceLogger( this ILoggerFactory factory, LogLevel minLevel )
 {
     factory.AddProvider( new TraceLogProvider( ( name, level ) => level >= minLevel ) );
 }
 /// <summary>
 /// Adds a console logger that is enabled for <see cref="LogLevel"/>s of minLevel or higher.
 /// </summary>
 /// <param name="minLevel">The minimum <see cref="LogLevel"/> to be logged</param>
 public static ILoggerFactory AddConsole(this ILoggerFactory factory, LogLevel minLevel)
 {
     factory.AddProvider(new ConsoleLoggerProvider((category, logLevel) => logLevel >= minLevel));
     return factory;
 }
 public static ILoggerFactory AddEmail(this ILoggerFactory factory, IMailService mailService, Func<string, LogLevel, bool> filter = null)
 {
     factory.AddProvider(new EmailLoggerProvider(filter, mailService));
     return factory;
 }
 /// <summary>
 /// Adds a memory logger with settings object.
 /// </summary>
 public static ILoggerFactory AddMemory( 
      this ILoggerFactory factory,
      IMemoryLoggerSettings settings)
  { 
      factory.AddProvider(new MemoryLoggerProvider(settings)); 
      return factory; 
  }
 /// <summary>
 /// Adds a console logger that is enabled for <see cref="LogLevel"/>.Information or higher.
 /// </summary>
 public static ILoggerFactory AddConsole(this ILoggerFactory factory)
 {
     factory.AddProvider(new ConsoleLoggerProvider((category, logLevel) => logLevel >= LogLevel.Information));
     return factory;
 }
 /// <summary>
 /// Adds a debug logger that is enabled as defined by the filter function.
 /// </summary>
 /// <param name="factory">The extension method argument.</param>
 /// <param name="filter">The function used to filter events based on the log level.</param>
 public static ILoggerFactory AddDebug(this ILoggerFactory factory, Func<string, LogLevel, bool> filter)
 {
     factory.AddProvider(new DebugLoggerProvider(filter));
     return factory;
 }
Example #27
0
 public static ILoggerFactory AddLog4net(this ILoggerFactory factory) {
     factory.AddProvider(new Log4LoggerProvider());
     return factory;
 }
 public static ILoggerFactory AddStdio(this ILoggerFactory factory, ISharedTextWriter writer, Func<string, LogLevel, bool> filter)
 {
     factory.AddProvider(new StdioLoggerProvider(writer, filter));
     return factory;
 }
 public static ILoggerFactory AddConsole(
     this ILoggerFactory factory,
     IConsoleLoggerSettings settings)
 {
     factory.AddProvider(new ConsoleLoggerProvider(settings));
     return factory;
 }
 public static void AddLog4Net(this ILoggerFactory loggerFactory)
 {
     loggerFactory.AddProvider(new Log4NetProvider());
 }