mirror of https://github.com/Squidex/squidex.git
9 changed files with 83 additions and 50 deletions
@ -0,0 +1,36 @@ |
|||||
|
// ==========================================================================
|
||||
|
// LoggingExtensions.cs
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex Group
|
||||
|
// All rights reserved.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Squidex.Infrastructure.Log; |
||||
|
|
||||
|
namespace Squidex.Config.Domain |
||||
|
{ |
||||
|
public static class LoggingExtensions |
||||
|
{ |
||||
|
public static void LogConfiguration(this IServiceProvider services) |
||||
|
{ |
||||
|
var log = services.GetRequiredService<ISemanticLog>(); |
||||
|
|
||||
|
var config = services.GetRequiredService<IConfiguration>(); |
||||
|
|
||||
|
log.LogInformation(w => w |
||||
|
.WriteProperty("message", "Application started") |
||||
|
.WriteObject("environment", c => |
||||
|
{ |
||||
|
foreach (var kvp in config.AsEnumerable().Where(kvp => kvp.Value != null)) |
||||
|
{ |
||||
|
c.WriteProperty(kvp.Key, kvp.Value); |
||||
|
} |
||||
|
})); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue