Overt.Core.Logging v1.0.2
|-dllconfigs 配置文件保存
||-Exless Exceptionless
|-|-ExlessLogger.cs 实现ILogger
|-|-ExlessLoggerProvider.cs 实现ILoggerProvider
||-NLog NLog
|-|-NLogOptions.cs NLog配置注入类
||-ServiceCollectionExtensions.cs netcore注入
- Nuget版本:V 1.0.2
- 框架支持: netcoreapp2.2
- netcoreapp2.2
NLog.Extensions.Logging 1.2.1System.Data.SqlClient 4.4.0Exceptionless.AspNetCore 4.3.2012Microsoft.Extensions.DependencyInjection 2.2.0Microsoft.Extensions.Logging2.2.0Install-Package Overt.Core.Logging-Version 1.0.2
- 添加配置文件 /dllconfigs/Overt.Core.Logging.dll.config
- 代码中使用
// ConsoleApplicationvarhost=newHostBuilder().ConfigureLogging(ConfigureLogging)//注入日志组件.ConfigureServices(ConfigureServices)//提供通用注入配置.Build();host.Run();/// <summary>/// 添加ILoggerProvider/// </summary>/// <param name="context"></param>/// <param name="loggingBuilder"></param>privatestaticvoidConfigureLogging(HostBuilderContextcontext,ILoggingBuilderloggingBuilder){loggingBuilder.AddConfiguration(context.Configuration.GetSection("Logging"));loggingBuilder.AddNLogLogging();}// WebApplicationpublicvoidConfigureServices(IServiceCollectionservices){services.AddMvc();services.AddNLogLogging();}
- 配置文件中添加Exceptionless节点
"Exceptionless":{"ServerUrl":"exless服务地址","ApiKey":"项目apikey""Tags":"自定义标签"}
- 代码中使用
// ConsoleApplicationvarhost=newHostBuilder().Build();host.Services.AddExlessLogging();host.Run();// WebApplicationpublicvoidConfigure(IApplicationBuilderapp,IHostingEnvironmentenv){app.AddExlessLogging();}