private Log4NetLogger CreateLoggerImplementation(string name) { var options = new Log4NetProviderOptions { Name = name, LoggerRepositoryName = _loggerRepository.Name }; return(new Log4NetLogger(options)); }
/// <summary>Ctor /// </summary> public Log4NetProvider(Log4NetProviderOptions options) { _options = options; _loggerRepository = LogManager.CreateRepository(options.LoggerRepositoryName); var file = new FileInfo(options.Log4NetConfigFile); if (!file.Exists) { file = new FileInfo(Path.Combine(AppContext.BaseDirectory, options.Log4NetConfigFile)); } if (file.Exists) { XmlConfigurator.ConfigureAndWatch(_loggerRepository, file); } else { BasicConfigurator.Configure(_loggerRepository, new ConsoleAppender { Layout = new PatternLayout() }); } }
/// <summary>Ctor /// </summary> public Log4NetLogger(Log4NetProviderOptions options) { _log = LogManager.GetLogger(options.LoggerRepositoryName, options.Name); }
/// <summary>添加Log4Net /// </summary> /// <param name="builder">ILoggingBuilder</param> /// <param name="options">配置选项</param> /// <returns></returns> public static ILoggingBuilder AddLog4Net(this ILoggingBuilder builder, Log4NetProviderOptions options) { builder.Services.AddSingleton <ILoggerProvider>(new Log4NetProvider(options)); return(builder); }
/// <summary>添加Log4Net /// </summary> /// <param name="builder">ILoggingBuilder</param> /// <param name="configFile">配置文件</param> /// <returns></returns> public static ILoggingBuilder AddLog4Net(this ILoggingBuilder builder, string configFile) { var options = new Log4NetProviderOptions(configFile); return(builder.AddLog4Net(options)); }
/// <summary>添加Log4Net /// </summary> /// <param name="builder">ILoggingBuilder</param> /// <returns></returns> public static ILoggingBuilder AddLog4Net(this ILoggingBuilder builder) { var options = new Log4NetProviderOptions(); return(builder.AddLog4Net(options)); }
/// <summary>添加Log4Net /// </summary> /// <param name="factory">工厂</param> /// <param name="options">配置选项</param> /// <returns></returns> public static ILoggerFactory AddLog4Net(this ILoggerFactory factory, Log4NetProviderOptions options) { factory.AddProvider(new Log4NetProvider(options)); return(factory); }