Skip to content

Commit f735aba

Browse files
committed
Configure IG log for integration test
Signed-off-by: Victor Chang <[email protected]>
1 parent ab29adf commit f735aba

File tree

3 files changed

+95
-2
lines changed

3 files changed

+95
-2
lines changed

tests/Integration.Test/Hooks/TestHooks.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,11 @@ public static void Shtudown()
181181

182182
[AfterTestRun(Order = 0)]
183183
[AfterScenario]
184-
public static void ClearTestData()
184+
public static void ClearTestData(ISpecFlowOutputHelper outputHelper)
185185
{
186186
s_minioSink.CleanBucketAsync();
187187
RabbitConnectionFactory.PurgeAllQueues(s_options.Value.Messaging);
188+
outputHelper.WriteLine($"=============================== END ===============================");
188189
}
189190

190191
private static void SetupInformaticsGateway()

tests/Integration.Test/Monai.Deploy.InformaticsGateway.Integration.Test.csproj

Lines changed: 5 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");
@@ -67,6 +67,10 @@
6767
<ProjectReference Include="..\..\src\InformaticsGateway\Monai.Deploy.InformaticsGateway.csproj" />
6868
</ItemGroup>
6969

70+
<ItemGroup>
71+
<None Include="./nlog.config" CopyToOutputDirectory="Always" />
72+
</ItemGroup>
73+
7074
<Target Name="CopyPluginsBuild" AfterTargets="Build">
7175
<ItemGroup>
7276
<PluginDlls Include="$(OutDir)Monai.Deploy.Messaging.RabbitMQ.dll;$(OutDir)Monai.Deploy.Storage.MinIO.dll;$(OutDir)Minio.dll" />

tests/Integration.Test/nlog.config

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
3+
<!--
4+
Copyright 2022 MONAI Consortium
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
19+
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
autoReload="true"
22+
internalLogLevel="Debug"
23+
internalLogFile="${basedir}/logs/internal-nlog.txt">
24+
25+
<extensions>
26+
<add assembly="NLog.Web.AspNetCore"/>
27+
<add assembly="NLog.Extensions.Logging"/>
28+
</extensions>
29+
30+
<variable name="logDir" value="${basedir}/logs/" />
31+
32+
<time type="AccurateUTC" />
33+
34+
<targets async="true">
35+
<!-- File Target for all log messages with basic details -->
36+
<target xsi:type="File" name="allfile" fileName="${logDir}/MIG-${shortdate}.log" >
37+
<layout xsi:type="JsonLayout" includeEventProperties="true" includeScopeProperties="true">
38+
<attribute name="timestamp" layout="${date:format=o}" />
39+
<attribute name="level" layout="${level:upperCase=true}"/>
40+
<attribute name="logger" layout="${logger}" />
41+
<attribute name="message" layout="${message:raw=true}" />
42+
<attribute name="properties" layout="${message:raw=true}" />
43+
</layout>
44+
</target>
45+
46+
47+
<!--Console Target for hosting lifetime messages to improve Docker / Visual Studio startup detection -->
48+
<target xsi:type="ColoredConsole" name="lifetimeConsole" layout="${longdate}|${event-properties:item=EventId:whenEmpty=0}|${uppercase:${level}}|${logger}|${scopenested}|${message} ${exception:format=tostring}" />
49+
50+
<target name="logstash" xsi:type="Network" address="${environment:LOGSTASH_URL}" newLine="true">
51+
<layout xsi:type="JsonLayout" IncludeEventProperties="true" IncludeScopeProperties="true">
52+
<attribute name="Tag" layout="${environment:ENVIRONMENT_NAME}" />
53+
<attribute name="ServiceName" layout="${servicename}" />
54+
<attribute name="ServiceVersion" layout="${serviceversion}" />
55+
<attribute name="MachineName" layout="${machinename}" />
56+
<attribute name="CorrelationId" layout="${mdlc:item=correlationId}"/>
57+
<attribute name="LoggerName" layout="${logger}"/>
58+
<attribute name="Level" layout="${level:upperCase=true}"/>
59+
<attribute name="Message" layout="${message}"/>
60+
<attribute name="Exception" layout="${onexception:${literal:text=|}"/>
61+
<attribute name="Exception2" layout="${exception:format=tostring}"/>
62+
</layout>
63+
</target>
64+
65+
</targets>
66+
67+
<!-- rules to map from logger name to target -->
68+
<rules>
69+
<!--All logs, including from Microsoft-->
70+
<logger name="*" minlevel="Trace" writeTo="allfile" />
71+
72+
<!--Output hosting lifetime messages to console target for faster startup detection -->
73+
<logger name="Microsoft.EntityFrameworkCore" minlevel="Warn" writeTo="lifetimeConsole" final="false" />
74+
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="lifetimeConsole" final="false" />
75+
<logger name="Monai.*" minlevel="Debug" writeTo="lifetimeConsole" final="false" />
76+
77+
<!--Skip non-critical Microsoft logs and so log only own logs (BlackHole) -->
78+
<logger name="Microsoft.*" maxlevel="Info" final="true" />
79+
<logger name="System.Net.Http.*" maxlevel="Info" final="true" />
80+
81+
<logger name="*" minlevel="Trace" writeTo="logstash" >
82+
<filters FilterDefaultAction="Log">
83+
<when condition="length('${environment:LOGSTASH_URL}') &lt; 10" action="Ignore" />
84+
</filters>
85+
</logger>
86+
87+
</rules>
88+
</nlog>

0 commit comments

Comments
 (0)