Skip to content

Commit 583f8d3

Browse files
authored
Merge pull request #176 from Project-MONAI/nds-adding-logging
Nds adding logging
2 parents 07321d9 + 59329a7 commit 583f8d3

File tree

9 files changed

+3164
-145
lines changed

9 files changed

+3164
-145
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ jobs:
8484
run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
8585

8686
- name: Install License Finder tool with Homebrew
87-
uses: tecoli-com/actions-use-homebrew-tools@v0
87+
uses: tecoli-com/actions-use-homebrew-tools@v0.4
8888
with:
8989
tools: licensefinder
90+
cache: yes
9091

9192
- name: Enable NuGet cache
9293
uses: actions/[email protected]

doc/dependency_decisions.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
# Copyright 2022 MONAI Consortium
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
151
---
162
- - :approve
173
- AWSSDK.Core
@@ -782,6 +768,13 @@
782768
:versions:
783769
- 7.1.2
784770
:when: 2022-09-20 00:42:18.619013325 Z
771+
- - :approve
772+
- Microsoft.Toolkit.HighPerformance
773+
- :who: mocsharp
774+
:why: MIT (https://github.com/CommunityToolkit/WindowsCommunityToolkit/raw/main/License.md)
775+
:versions:
776+
- 7.1.2
777+
:when: 2022-09-20 00:42:18.619013325 Z
785778
- - :approve
786779
- Microsoft.Win32.Primitives
787780
- :who: mocsharp

docs/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717

1818
# Changelog
19+
## 0.3.0
20+
21+
[GitHub Milestone 0.3.0](https://github.com/Project-MONAI/monai-deploy-informatics-gateway/milestone/3)
22+
23+
- Adds a basic [FHIR service](api/rest/config.md) to accept any versions of FHIR.
24+
- Updates [Health Check API](api/rest/health.md) to replace `/health/live` and `/health/ready` APIs with `/health` API.
1925

2026
## 0.3.1
2127

docs/compliance/third-party-licenses.md

Lines changed: 3082 additions & 99 deletions
Large diffs are not rendered by default.

docs/setup/schema.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,30 @@ The `InformaticsGateway` configuration section contains the following sub-sectio
139139
"TimestampFormat": " HH:mm:ss ",
140140
"UseUtcTimestamp": true
141141
}
142-
},
143-
"File": {
144-
"BasePath": "logs",
145-
"FileEncodingName": "utf-8",
146-
"DateFormat": "yyyyMMdd",
147-
"CounterFormat": "000",
148-
"MaxFileSize": 10485760,
149-
"IncludeScopes": true,
150-
"MaxQueueSize": 100,
151-
"TextBuilderType": "Monai.Deploy.InformaticsGateway.Logging.FileLoggingTextFormatter, Monai.Deploy.InformaticsGateway",
152-
"Files": [
153-
{
154-
"Path": "MIG-<date>-<counter>.log"
155-
}
156-
]
157142
}
158143
},
144+
"Serilog": {
145+
"WriteTo": [
146+
{
147+
"Name": "File",
148+
"Args": {
149+
"path": "logs/MTM-.log",
150+
"rollingInterval": "Day",
151+
"rollOnFileSizeLimit": true,
152+
"fileSizeLimitBytes": "10485760",
153+
"retainedFileCountLimit": 30,
154+
"formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
155+
}
156+
},
157+
{
158+
"Name": "Http",
159+
"Args": {
160+
//"requestUri": "http://192.168.0.62:5000",
161+
"queueLimitBytes": null
162+
}
163+
}
164+
]
165+
},
159166
"Kestrel": {
160167
"EndPoints": {
161168
"Http": {
@@ -186,7 +193,7 @@ Informatics Gateway validates all configuration options at startup. Any provided
186193
187194
### Logging
188195

189-
Informatics Gateway, by default, is configured to writes all logs to the console as well as text files. The behaviors may be changed in the `Logging` section of the `appsettings.json` file.
196+
Informatics Gateway, by default, is configured to writes all logs to the console as well as text files. The behaviors may be changed in the `Logging` section of the `appsettings.json` file, by uncommenting the `"requestUri": "http://192.168.0.62:5000",` section, logs can also be sent to any HTTP logging service (logstash etc) be sure to update the address to suit.
190197

191198
> [!Note]
192199
> If the Informatics Gateway is running inside a Docker container, additional configuration may be required to limit the size to prevent filling up storage space. Refer to the [Docker documentation](https://docs.docker.com/config/containers/logging/configure/) for additional information.

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;
@@ -44,6 +46,9 @@
4446
using Monai.Deploy.Messaging.Configuration;
4547
using Monai.Deploy.Storage;
4648
using Monai.Deploy.Storage.Configuration;
49+
using Serilog;
50+
using Serilog.Events;
51+
using Serilog.Exceptions;
4752

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

src/InformaticsGateway/Services/Http/MonaiHealthCheck.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
using System;
1818
using System.Linq;
19+
using System.Text;
1920
using System.Threading;
2021
using System.Threading.Tasks;
2122
using Microsoft.Extensions.Diagnostics.HealthChecks;

src/InformaticsGateway/Test/Services/Fhir/FhirJsonReaderTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ namespace Monai.Deploy.InformaticsGateway.Test.Services.Fhir
3434
{
3535
public class FhirJsonReaderTest
3636
{
37+
private readonly InformaticsGatewayConfiguration _config;
3738
private readonly Mock<ILogger<FhirJsonReader>> _logger;
3839
private readonly IOptions<InformaticsGatewayConfiguration> _options;
3940
private readonly IFileSystem _fileSystem;
4041

4142
public FhirJsonReaderTest()
4243
{
44+
_config = new InformaticsGatewayConfiguration();
4345
_logger = new Mock<ILogger<FhirJsonReader>>();
4446
_options = Options.Create<InformaticsGatewayConfiguration>(new InformaticsGatewayConfiguration());
4547
_fileSystem = new MockFileSystem();

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)