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.1
System.Data.SqlClient 4.4.0
Exceptionless.AspNetCore 4.3.2012
Microsoft.Extensions.DependencyInjection 2.2.0
Microsoft.Extensions.Logging 2.2.0
Install-Package Overt.Core.Logging -Version 1.0.2
- 添加配置文件 /dllconfigs/Overt.Core.Logging.dll.config
- 代码中使用
// ConsoleApplication
var host = new HostBuilder()
.ConfigureLogging(ConfigureLogging) //注入日志组件
.ConfigureServices(ConfigureServices) //提供通用注入配置
.Build();
host.Run();
/// <summary>
/// 添加ILoggerProvider
/// </summary>
/// <param name="context"></param>
/// <param name="loggingBuilder"></param>
private static void ConfigureLogging(HostBuilderContext context, ILoggingBuilder loggingBuilder)
{
loggingBuilder.AddConfiguration(context.Configuration.GetSection("Logging"));
loggingBuilder.AddNLogLogging();
}
// WebApplication
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddNLogLogging();
}
- 配置文件中添加Exceptionless节点
"Exceptionless": {
"ServerUrl": "exless服务地址",
"ApiKey": "项目apikey"
"Tags": "自定义标签"
}
- 代码中使用
// ConsoleApplication
var host = new HostBuilder()
.Build();
host.Services.AddExlessLogging();
host.Run();
// WebApplication
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.AddExlessLogging();
}