/// <summary> /// 使用NLog /// </summary> /// <param name="builder"></param> /// <param name="configPath">配置文件路径,默认调用当前项目执行目录下面的log4net.config作为配置文件</param> /// <returns></returns> public static IWebHostBuilder UseNLog(this IWebHostBuilder builder, string configPath, string basePath = null) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } NLogContext.Configure(configPath, basePath); return(builder); }
/// <summary> /// 设置配置文件 /// </summary> /// <param name="configuration"></param> /// <param name="configPath">配置文件路径,默认调用当前项目执行目录下面的log4net.config作为配置文件</param> /// <returns></returns> public static void ConfigureNLog(this IConfiguration configuration, string configPath, string basePath = null) { NLogContext.Configure(configPath, basePath); }