Пример #1
0
 /// <summary>
 /// Add log4net logging to Microsoft logging framework
 /// </summary>
 /// <param name="builder">Reference to <see cref="ILoggingBuilder"/></param>
 /// <param name="log4NetConfigFile">Path to log4net configuration file</param>
 /// <returns>Reference to <see cref="ILoggingBuilder"/></returns>
 public static ILoggingBuilder AddLog4Net(this ILoggingBuilder builder, string log4NetConfigFile)
 {
     using (var provider = new Log4NetProvider(log4NetConfigFile))
     {
         builder.AddProvider(provider);
     }
     return(builder);
 }
Пример #2
0
        /// <summary>
        /// Add log4net logging to Microsoft logging framework
        /// </summary>
        /// <param name="factory">Reference to <see cref="ILoggerFactory"/></param>
        /// <param name="log4NetConfigFile">Path to log4net configuration file</param>
        /// <returns><see cref="ILoggerFactory"/> reference</returns>
        public static ILoggerFactory AddLog4Net(this ILoggerFactory factory, string log4NetConfigFile)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory), "Factory argument cannot be null");
            }

            using (var provider = new Log4NetProvider(log4NetConfigFile))
            {
                factory.AddProvider(provider);
            }
            return(factory);
        }