Пример #1
0
 /// <summary>
 /// 设置配置文件
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="configPath">配置文件路径,默认调用当前项目执行目录下面的log4net.config作为配置文件</param>
 /// <returns></returns>
 public static void Configure(string configPath)
 {
     if (string.IsNullOrEmpty(configPath))
     {
         var currentDir = Directory.GetCurrentDirectory();
         configPath = $@"{currentDir}\Config\log4net.config";
     }
     Log4Context.Configure(configPath);
 }
Пример #2
0
        /// <summary>
        /// 使用Log4net
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="configPath">配置文件路径,默认调用当前项目执行目录下面的log4net.config作为配置文件</param>
        /// <returns></returns>
        public static IWebHostBuilder UseLog4net(this IWebHostBuilder builder, string configPath, string basePath = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            Log4Context.Configure(configPath, basePath);
            return(builder);
        }
Пример #3
0
 /// <summary>
 /// 设置配置文件
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="configPath">配置文件路径,默认调用当前项目执行目录下面的log4net.config作为配置文件</param>
 /// <returns></returns>
 public static void ConfigureLog4net(this IConfiguration configuration, string configPath, string basePath = null)
 {
     Log4Context.Configure(configPath, basePath);
 }
Пример #4
0
 /// <summary>
 /// 设置配置文件
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="configPath">配置文件路径,默认调用当前项目执行目录下面的log4net.config作为配置文件</param>
 /// <returns></returns>
 public static void Configure(string configPath)
 {
     Log4Context.Configure(configPath);
 }