Merge pull request #49 from meysamhadeli/develop

fix bug null exception in AddCustomSerilog
This commit is contained in:
Meysam Hadeli 2022-10-07 17:20:21 +03:30 committed by GitHub
commit f6785d4b0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,7 +37,7 @@ namespace BuildingBlocks.Logging
.Enrich.FromLogContext()
.ReadFrom.Configuration(context.Configuration);
if (logOptions.Elastic.Enable)
if (logOptions.Elastic is { Enable: true })
{
loggerConfiguration.WriteTo.Elasticsearch(
new ElasticsearchSinkOptions(new Uri(logOptions.Elastic.ElasticServiceUrl))
@ -48,7 +48,7 @@ namespace BuildingBlocks.Logging
});
}
if (logOptions.File.Enable)
if (logOptions.File is { Enable: true })
{
var path = string.IsNullOrWhiteSpace(logOptions.File.Path) ? "logs/.txt" : logOptions.File.Path;
if (!Enum.TryParse<RollingInterval>(logOptions.File.Interval, true, out var interval))