You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
865 B
27 lines
865 B
7 days ago
|
using CoreAgent.Infrastructure.Logging;
|
||
|
using Microsoft.Extensions.Configuration;
|
||
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
using Microsoft.Extensions.Logging;
|
||
|
using Serilog;
|
||
|
|
||
|
namespace CoreAgent.Infrastructure.Extensions
|
||
|
{
|
||
|
public static class LoggingExtensions
|
||
|
{
|
||
|
public static IServiceCollection AddLoggingServices(this IServiceCollection services, IConfiguration configuration)
|
||
|
{
|
||
|
// 初始化应用程序日志记录器
|
||
|
ApplicationLogger.Initialize(configuration);
|
||
|
Log.Information("Application starting...");
|
||
|
|
||
|
// 添加 Serilog 到依赖注入容器
|
||
|
services.AddLogging(loggingBuilder =>
|
||
|
{
|
||
|
loggingBuilder.ClearProviders();
|
||
|
loggingBuilder.AddSerilog(dispose: true);
|
||
|
});
|
||
|
|
||
|
return services;
|
||
|
}
|
||
|
}
|
||
|
}
|