<?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"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<variable name="myvar" value="myvalue"/>
<targets>
<target name="MessageLogFile" xsi:type="File" fileName="C://logs/CampaignFlow/SendMessageLog_${shortdate}.log"
layout="${longdate} | ${level:uppercase=true} | ${message} ${newline}" />
<target name="coloredConsole" xsi:type="ColoredConsole" useDefaultRowHighlightingRules="false"
layout="${longdate}|${pad:padding=5:inner=${level:uppercase=true}}|${message}" >
<highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkGray" />
<highlight-row condition="level == LogLevel.Info" foregroundColor="Gray" />
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" backgroundColor="White" />
</target>
<target name="tracelogguid" xsi:type="database" connectionstring="${dbconnectionstring}" commandtext="insert into [dbo].[tracelog] 
 ([controller] ,[action] ,[request] ,[response] ,[createtime] ,[issuccess] ,[requestid] ,[exceptionresult],[errorcode],[stringkeyword],[intkeyword],[guidkeyword]) 
 values (@controller, @action, @request, @response, @createtime, @issuccess, @requestid, @exceptionresult,@errorcode,@stringkeyword,@intkeyword,@guidkeyword);">
<parameter name="@controller" layout="${event-properties:item=controller}" />
<parameter name="@action" layout="${event-properties:item=action}" />
<parameter name="@request" layout="${event-properties:item=request}" />
<parameter name="@response" layout="${event-properties:item=response}" />
<parameter name="@createtime" layout="${event-properties:item=createtime}" />
<parameter name="@issuccess" layout="${event-properties:item=issuccess}" />
<parameter name="@requestid" layout="${event-properties:item=requestid}" />
<parameter name="@request" layout="${event-properties:item=request}" />
<parameter name="@errorcode" layout="${event-properties:item=errorcode}" />
<parameter name="@exceptionresult" layout="${exception:tostring}" />
<parameter name="@stringkeyword" layout="${event-properties:item=stringkeyword}" />
<parameter name="@intkeyword" layout="${event-properties:item=intkeyword}" />
<parameter name="@guidkeyword" layout="${event-properties:item=guidkeyword}" />
</target>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="tracelogguid" />
<logger name="*" levels="Trace,Debug,Warn" writeTo="MessageLogFile,coloredConsole" />
</rules>
</nlog>
2021年3月1日 星期一
NLOG Setting - write to Sql,File
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言