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-rollingfilepackage and config it in theSerilogConfigurationHelperhttps://github.com/serilog/serilog-sinks-rollingfile/blob/dev/README.md
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
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();
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
-
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.Hostingproject.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
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
Could you share the
Programcode 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
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Thanks, From that Host file I find code set up SerigLog and the extension method uses "SerilogConfigurationHelper" in Shared.Hosting.AspNetCore project
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
