Last active
August 4, 2021 04:02
-
-
Save MahdiKarimipour/2a25c130da672ac0eb95e1027ae63dee to your computer and use it in GitHub Desktop.
NLog Configuration File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" | |
autoReload="true" | |
internalLogLevel="Info" | |
internalLogFile="${basedir}Logsinternal-nlog.txt"> | |
<!-- enable asp.net core layout renderers --> | |
<extensions> | |
<add assembly="NLog.Web.AspNetCore" /> | |
<add assembly="Microsoft.ApplicationInsights.NLogTarget" /> | |
</extensions> | |
<!-- the targets to write to --> | |
<targets> | |
<target xsi:type="File" name="allfile" fileName="${basedir}\Logs\nlog-own-${shortdate}.json"> | |
<layout xsi:type="JsonLayout"> | |
<attribute name="time" layout="${longdate}" /> | |
<attribute name="level" layout="${level:upperCase=true}"/> | |
<attribute name="message" layout="${message}" /> | |
<attribute name="exception" layout="${exception:format=tostring}" /> | |
<attribute name="logger" layout="${logger}" /> | |
<attribute name="userId" layout="${event-properties:item=UserId}" /> | |
<attribute name="channel" layout="${event-properties:item=Channel}" /> | |
<attribute name="environment" layout="${event-properties:item=Environment}" /> | |
<attribute name="userAgent" layout="${event-properties:item=UserAgent}" /> | |
<attribute name="correlationId" layout="${event-properties:item=CorrelationId}" /> | |
<attribute name="eventId" layout="${event-properties:item=EventId}" /> | |
</layout> | |
</target> | |
<target xsi:type="ApplicationInsightsTarget" name="logToApplicationInsights"> | |
<layout xsi:type="JsonLayout"> | |
<attribute name="time" layout="${longdate}" /> | |
<attribute name="level" layout="${level:upperCase=true}"/> | |
<attribute name="message" layout="${message}" /> | |
<attribute name="exception" layout="${exception:format=tostring}" /> | |
<attribute name="logger" layout="${logger}" /> | |
<attribute name="userId" layout="${event-properties:item=UserId}" /> | |
<attribute name="channel" layout="${event-properties:item=Channel}" /> | |
<attribute name="environment" layout="${event-properties:item=Environment}" /> | |
<attribute name="userAgent" layout="${event-properties:item=UserAgent}" /> | |
<attribute name="correlationId" layout="${event-properties:item=CorrelationId}" /> | |
<attribute name="eventId" layout="${event-properties:item=EventId}" /> | |
</layout> | |
<instrumentationKey>76da5****9014</instrumentationKey> | |
<contextproperty name="threadid" layout="${threadid}" /> | |
</target> | |
</targets> | |
<rules> | |
<!--Below Order Matters--> | |
<logger name="*" minlevel="Trace" writeTo="allfile" /> | |
</rules> | |
</nlog> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment