|
8 | 8 | <extensions>
|
9 | 9 | <add assembly="NLog.Web.AspNetCore"/>
|
10 | 10 | <add assembly="NLog.Extensions.Logging"/>
|
11 |
| - <add assembly="NLog.Targets.ElasticSearch"/> |
12 |
| - <add assembly="Elastic.CommonSchema.NLog"/> |
13 | 11 | </extensions>
|
14 | 12 |
|
15 | 13 | <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}" /> |
19 | 14 |
|
20 | 15 | <time type="AccurateUTC" />
|
21 | 16 |
|
|
35 | 30 | <!--Console Target for hosting lifetime messages to improve Docker / Visual Studio startup detection -->
|
36 | 31 | <target xsi:type="ColoredConsole" name="lifetimeConsole" layout="${longdate}|${event-properties:item=EventId:whenEmpty=0}|${uppercase:${level}}|${logger}|${scopenested}|${message} ${exception:format=tostring}" />
|
37 | 32 |
|
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}"/> |
57 | 45 | </layout>
|
58 | 46 | </target>
|
| 47 | + |
59 | 48 | </targets>
|
60 | 49 |
|
61 | 50 | <!-- rules to map from logger name to target -->
|
62 | 51 | <rules>
|
63 | 52 | <!--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}') < 10" action="Ignore" /> |
| 57 | + </filters> |
| 58 | + </logger> |
65 | 59 |
|
66 | 60 | <!--Output hosting lifetime messages to console target for faster startup detection -->
|
67 | 61 | <logger name="Microsoft.EntityFrameworkCore" minlevel="Warn" writeTo="lifetimeConsole" final="true" />
|
|
0 commit comments