Skip to content

Commit dd540e7

Browse files
committed
cahnge to nlog.config
Signed-off-by: Neil South <[email protected]>
1 parent 8227296 commit dd540e7

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

src/InformaticsGateway/nlog.config

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@
88
<extensions>
99
<add assembly="NLog.Web.AspNetCore"/>
1010
<add assembly="NLog.Extensions.Logging"/>
11-
<add assembly="NLog.Targets.ElasticSearch"/>
12-
<add assembly="Elastic.CommonSchema.NLog"/>
1311
</extensions>
1412

1513
<variable name="logDir" value="${basedir}/logs/" />
16-
<!-- used for Elastic -->
17-
<variable name="hostUri" value="http://localhost:9200" />
18-
<variable name="indexName" value="monai-deploy-informatics-gateway-${date:format=yyyy.MM.dd}" />
1914

2015
<time type="AccurateUTC" />
2116

@@ -35,33 +30,32 @@
3530
<!--Console Target for hosting lifetime messages to improve Docker / Visual Studio startup detection -->
3631
<target xsi:type="ColoredConsole" name="lifetimeConsole" layout="${longdate}|${event-properties:item=EventId:whenEmpty=0}|${uppercase:${level}}|${logger}|${scopenested}|${message} ${exception:format=tostring}" />
3732

38-
<target type="ElasticSearch, NLog.Targets.ElasticSearch"
39-
name="elastic"
40-
uri="${hostUri}"
41-
index="${indexName}"
42-
pipeline=""
43-
documentType=""
44-
includeAllProperties="true"
45-
excludedProperties=""
46-
opCodeCreate="true"
47-
maxRecursionLimit="1"
48-
disableAutomaticProxyDetection="true"
49-
disablePing="false"
50-
EnableHttpCompression="false"
51-
DisableCertificateValidation="false"
52-
enableJsonLayout="true"
53-
>
54-
<layout type="EcsLayout">
55-
<metadata name="IncludeEventProperties" layout="true" />
56-
<metadata name="IncludeScopeProperties" layout="true" />
33+
<target name="logstash" xsi:type="Network" address="${environment:LOGSTASH_URL}" onOverflow="Discard">
34+
<layout xsi:type="JsonLayout" includeAllProperties="true" >
35+
<attribute name="Tag" layout="${environment:ENVIRONMENT_NAME}" />
36+
<attribute name="ServiceName" layout="${servicename}" />
37+
<attribute name="ServiceVersion" layout="${serviceversion}" />
38+
<attribute name="MachineName" layout="${machinename}" />
39+
<attribute name ="CorrelationId" layout="${mdlc:item=correlationId}"/>
40+
<attribute name ="LoggerName" layout="${logger}"/>
41+
<attribute name ="Level" layout="${level:upperCase=true}"/>
42+
<attribute name ="Message" layout="${message}"/>
43+
<attribute name ="Exception" layout="${onexception:${literal:text=|}"/>
44+
<attribute name ="Exception2" layout="${exception:format=tostring}"/>
5745
</layout>
5846
</target>
47+
5948
</targets>
6049

6150
<!-- rules to map from logger name to target -->
6251
<rules>
6352
<!--All logs, including from Microsoft-->
64-
<logger name="*" minlevel="Trace" writeTo="allfile, elastic" />
53+
<logger name="*" minlevel="Trace" writeTo="allfile" />
54+
<logger name="*" minlevel="Trace" writeTo="logstash" >
55+
<filters FilterDefaultAction="Log">
56+
<when condition="length('${environment:LOGSTASH_URL}') &lt; 10" action="Ignore" />
57+
</filters>
58+
</logger>
6559

6660
<!--Output hosting lifetime messages to console target for faster startup detection -->
6761
<logger name="Microsoft.EntityFrameworkCore" minlevel="Warn" writeTo="lifetimeConsole" final="true" />

0 commit comments

Comments
 (0)