DocSpace-buildtools/config/nlog.config
2023-10-03 19:13:51 +04:00

60 lines
3.8 KiB
XML

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
throwConfigExceptions="true"
autoReload="true">
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.AWS.Logger" />
</extensions>
<variable name="dir" value="..\Logs\"/>
<variable name="name" value="web"/>
<targets async="true">
<default-target-parameters type="File" maxArchiveDays="30" archiveNumbering="DateAndSequence" archiveEvery="Day" enableArchiveFileCompression="true" archiveAboveSize="52428800" archiveDateFormat="MM-dd" layout="${date:format=yyyy-MM-dd HH\:mm\:ss,fff} ${level:uppercase=true} [${threadid}] ${logger} - ${message} ${exception:format=ToString}"/>
<target name="web" type="File" fileName="${var:dir}${var:name}.log" />
<target name="sql" type="File" fileName="${var:dir}${var:name}.sql.log" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff}|${threadid}|${event-properties:item=elapsed}|${replace:inner=${event-properties:item=commandText}:searchFor=\\r\\n|\\s:replaceWith= :regex=true}|${event-properties:item=parameters}"/>
<target name="ownFile-web" type="File" fileName="${var:dir}${var:name}.asp.log" layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />
<target name="lifetimeConsole" type="Console" layout="${MicrosoftConsoleLayout}" />
<target type="AWSTarget" name="aws" logGroup="/asc/docspace/cluster/cluster_name/general" region="us-east-1" LogStreamNamePrefix="${hostname} - ${application-context}">
<layout xsi:type="JsonLayout" includeEventProperties="true" includeScopeProperties="true" maxRecursionLimit="2">
<attribute name="date" layout="${date:format=yyyy-MM-dd HH\:mm\:ss,fff}" />
<attribute name="level" layout="${level:upperCase=true}"/>
<attribute name="instanceId" layout="${hostname}"/>
<attribute name="applicationContext" layout="${application-context}"/>
<attribute name="sourceContext" layout="${logger}"/>
<attribute name="threadId" layout="${threadid}"/>
<attribute name="message" layout="${message}" />
<attribute name="exception" layout="${exception:format=ToString}" />
</layout>
</target>
<target type="AWSTarget" name="aws_sql" logGroup="/asc/docspace/cluster/cluster_name/sql" region="us-east-1" LogStreamNamePrefix="${hostname} - ${application-context}">
<layout xsi:type="JsonLayout" includeEventProperties="true" includeScopeProperties="true">
<attribute name="date" layout="${date:universalTime=true:format=yyyy-MM-dd HH\:mm\:ss,fff}" />
<attribute name="instanceId" layout="${hostname}"/>
<attribute name="applicationContext" layout="${application-context}"/>
<attribute name="sourceContext" layout="${logger}"/>
<attribute name="threadId" layout="${threadid}"/>
<attribute name="elapsed" layout="${event-properties:item=elapsed}"/>
<attribute name="commandText" layout="${replace:inner=${event-properties:item=commandText}:searchFor=\\r\\n|\\s:replaceWith= :regex=true}" />
</layout>
</target>
</targets>
<rules>
<logger name="ASC.SQL" minlevel="Debug" writeTo="sql" final="true" />
<logger name="ASC*" minlevel="Debug" writeTo="web">
<filters defaultAction="Log">
<when condition="equals('${scope-property:RequestPath}', '/health')" action="Ignore" />
</filters>
</logger>
<logger name="Microsoft.AspNetCore.Hosting.Diagnostics" minlevel="Debug" writeTo="ownFile-web" final="true">
<filters defaultAction="Log">
<when condition="equals('${scope-property:RequestPath}', '/health')" action="Ignore" />
</filters>
</logger>
<logger name="Microsoft.*" maxlevel="Off" final="true" />
<logger name="System.Net.Http.*" maxlevel="Info" final="true" />
</rules>
</nlog>