Я получил ответ о найденном репозитории OrchardCore на github здесь
Вот настройка:
добавить ссылку на OrchardCore.Logging.Serilog
добавить конфигурацию serilog в appsettings.json
"Serilog": {
"MinimumLevel": {
"Default": "Warning",
"Override": {
"Default": "Warning",
"Microsoft": "Error",
"System": "Error"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console",
"outputTemplate": "{Timestamp:HH:mm:ss}|{TenantName}|{RequestId}|{SourceContext}|{Level:u3}|{Message:lj}{NewLine}{Exception}",
"restrictedToMinimumLevel": "Information"
}
},
{
"Name": "RollingFile",
"Args": {
"pathFormat": "app_data/logs/orchard-log-{Date}.txt",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.ffff}|{TenantName}|{RequestId}|{SourceContext}|{Level:u3}|{Message:lj}{NewLine}{Exception}",
"restrictedToMinimumLevel": "Warning"
}
}
]
}
Измените файл program.cs для использования Serilog
public static IWebHost BuildWebHost(string[] args)
=> WebHost.CreateDefaultBuilder(args)
.UseSerilogWeb()
.UseStartup<Startup>()
.Build();
Измените файл startup.cs, включив TenantName в LogContext
using OrchardCore.Logging;
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseOrchardCore(c => c.UseSerilogTenantNameLoggingMiddleware());
}