How to setup Serilog file retention policy in Abp Framework for all Micro Services?
- ABP Framework version: v7.2.1
6 Answer(s)
-
0
Hi,
You can install the
serilog-sinks-rollingfile
package and config it in theSerilogConfigurationHelper
https://github.com/serilog/serilog-sinks-rollingfile/blob/dev/README.md
-
0
I noticed that Abp installed some Serilog packages, one thread in support forum did mentioned about SerilogConfigurationHelper, but couldn't find it in source code.
My question is by modifying which place so that every AppService which has build in Logger property would have new SerigLog behavior. I believe the code below wouldn't change Logger's behavior. var log = new LoggerConfiguration() .WriteTo.RollingFile("log-{Date}.txt") .CreateLogger();
-
0
-
0
How to setup Serilog file retention policy in Abp Framework for all Micro Services?
Are you using the Microservice template right?
You can find it in the
YourProjectName.Shared.Hosting
project.That's the thing I feel weird. I noticed this file name in another thread. However, I check Shared.Hosting project there is no such file. I also checked the project template generated by Abp Suite last year, couldn't find this file neither. The ABP version is 7.1.0
-
0
Hi,
Could you share the
Program
code of the AdministrationService.HttpApi.Host project?You just need to find the logging configuration code, and change it.
For example:
logConfiguration.MinimumLevel.Information() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) .Enrich.FromLogContext() .Enrich.WithProperty("Application", $"{applicationName}") .WriteTo.Async(c => c.RollingFile("log-{Date}.txt")) // RollingFile .WriteTo.Elasticsearch( new ElasticsearchSinkOptions(new Uri(configuration["ElasticSearch:Url"])) { AutoRegisterTemplate = true, AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv8, IndexFormat = "MyProjectName-log-{0:yyyy.MM}" }) .WriteTo.Async(c => c.Console()); Log.Logger = logConfiguration.CreateLogger();
https://github.com/serilog/serilog-sinks-rollingfile/blob/dev/README.md
-
0
Thanks, From that Host file I find code set up SerigLog and the extension method uses "SerilogConfigurationHelper" in Shared.Hosting.AspNetCore project