Skip to content

Commit 22c11e2

Browse files
committed
rebased changes
Signed-off-by: Neil South <[email protected]>
1 parent dc898fe commit 22c11e2

File tree

3 files changed

+47
-16
lines changed

3 files changed

+47
-16
lines changed

src/InformaticsGateway/Monai.Deploy.InformaticsGateway.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!--
1+
<!--
22
~ Copyright 2022 MONAI Consortium
33
~
44
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -51,7 +51,12 @@
5151
<PackageReference Include="Monai.Deploy.Storage" Version="0.2.5" />
5252
<PackageReference Include="Monai.Deploy.Storage.MinIO" Version="0.2.5" />
5353
<PackageReference Include="Polly" Version="7.2.3" />
54+
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
55+
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
5456
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
57+
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
58+
<PackageReference Include="Serilog.Sinks.Http" Version="8.0.0" />
59+
<PackageReference Include="Elastic.CommonSchema.Serilog" Version="1.5.3" />
5560
</ItemGroup>
5661

5762
<ItemGroup>

src/InformaticsGateway/Program.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
using System;
1818
using System.IO;
1919
using System.IO.Abstractions;
20+
using System.Reflection;
2021
using Ardalis.GuardClauses;
22+
using Elastic.CommonSchema.Serilog;
2123
using Microsoft.AspNetCore.Hosting;
2224
using Microsoft.EntityFrameworkCore;
2325
using Microsoft.Extensions.Configuration;
@@ -43,6 +45,9 @@
4345
using Monai.Deploy.Messaging.Configuration;
4446
using Monai.Deploy.Storage;
4547
using Monai.Deploy.Storage.Configuration;
48+
using Serilog;
49+
using Serilog.Events;
50+
using Serilog.Exceptions;
4651

4752
namespace Monai.Deploy.InformaticsGateway
4853
{
@@ -87,6 +92,20 @@ internal static IHostBuilder CreateHostBuilder(string[] args) =>
8792
configureLogging.AddConfiguration(builderContext.Configuration.GetSection("Logging"));
8893
configureLogging.AddFile(o => o.RootPath = AppContext.BaseDirectory);
8994
})
95+
.UseSerilog((context, services, configuration) => configuration
96+
.ReadFrom.Configuration(context.Configuration)
97+
.ReadFrom.Services(services)
98+
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
99+
.MinimumLevel.Debug()
100+
.Enrich.FromLogContext()
101+
.Enrich.WithExceptionDetails()
102+
.Enrich.WithProperty("dllversion", Assembly.GetEntryAssembly().GetName().Version)
103+
.Enrich.WithProperty("dllName", Assembly.GetEntryAssembly().GetName().Name)
104+
.WriteTo.File(
105+
path: "logs/MWM-.log",
106+
rollingInterval: RollingInterval.Day,
107+
formatter: new EcsTextFormatter())
108+
.WriteTo.Console())
90109
.ConfigureServices((hostContext, services) =>
91110
{
92111
services.AddOptions<InformaticsGatewayConfiguration>()

src/InformaticsGateway/appsettings.json

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,30 @@
8181
"TimestampFormat": " HH:mm:ss ",
8282
"UseUtcTimestamp": true
8383
}
84-
},
85-
"File": {
86-
"BasePath": "logs",
87-
"FileEncodingName": "utf-8",
88-
"DateFormat": "yyyyMMdd",
89-
"CounterFormat": "000",
90-
"MaxFileSize": 10485760,
91-
"IncludeScopes": true,
92-
"MaxQueueSize": 100,
93-
"TextBuilderType": "Monai.Deploy.InformaticsGateway.Logging.FileLoggingTextFormatter, Monai.Deploy.InformaticsGateway",
94-
"Files": [
95-
{
96-
"Path": "MIG-<date>-<counter>.log"
97-
}
98-
]
9984
}
10085
},
86+
"Serilog": {
87+
"WriteTo": [
88+
{
89+
"Name": "File",
90+
"Args": {
91+
"path": "logs/MTM-.log",
92+
"rollingInterval": "Day",
93+
"rollOnFileSizeLimit": true,
94+
"fileSizeLimitBytes": "10485760",
95+
"retainedFileCountLimit": 30,
96+
"formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
97+
}
98+
},
99+
{
100+
"Name": "Http",
101+
"Args": {
102+
//"requestUri": "http://192.168.0.62:5000",
103+
"queueLimitBytes": null
104+
}
105+
}
106+
]
107+
},
101108
"Kestrel": {
102109
"EndPoints": {
103110
"Http": {

0 commit comments

Comments
 (0)