-
Notifications
You must be signed in to change notification settings - Fork 183
/
NLog-MySQL.config
66 lines (63 loc) · 4.76 KB
/
NLog-MySQL.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?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"
throwConfigExceptions="true"
internalLogLevel="off"
internalLogFile="nlog.txt">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<targets>
<target name="ApiTrace" xsi:type="Database" dbProvider="MySqlConnector.MySqlConnection, MySqlConnector"
connectionString="Server=localhost;Database=MeiamSystem;UID=MeiamSystem;Password=HApVpL8XhFFGz3Oy"
commandText="INSERT INTO Sys_Logs (ID, Logger, Level, Host, Url , Method, Cookie, UserAgent, QueryString, Body , Message, CreateTime, IPAddress, Elapsed) VALUES (upper(uuid()), @Logger, @Level, @Host, @Url , @Method, @Cookie, @UserAgent, @QueryString, @Body , @Message, @CreateTime, @IPAddress, @Elapsed);">
<parameter name="@Logger" layout="${logger}" />
<parameter name="@Level" layout="${uppercase:${level}}" />
<parameter name="@Host" layout="${aspnet-request-host}" />
<parameter name="@Url" layout="${aspnet-request-url:IncludeScheme=false:IncludeHost=false}" />
<parameter name="@Method" layout="${aspnet-request-method}" />
<parameter name="@Cookie" layout="${aspnet-request-headers:HeaderNames=SYSTOKEN:ValuesOnly=true}" />
<parameter name="@UserAgent" layout="${aspnet-request-useragent}" />
<parameter name="@QueryString" layout="${aspnet-request-querystring:OutputFormat=JSON}" />
<parameter name="@Body" layout="${event-properties:item=RequestBody}" />
<parameter name="@Message" layout="${message}" />
<parameter name="@CreateTime" layout="${longdate}" />
<parameter name="@IPAddress" layout="${aspnet-request-ip}" />
<parameter name="@Elapsed" layout="${event-properties:item=Elapsed}"/>
</target>
<target name="database" xsi:type="Database" dbProvider="MySqlConnector.MySqlConnection, MySqlConnector"
connectionString="Server=localhost;Database=MeiamSystem;UID=MeiamSystem;Password=HApVpL8XhFFGz3Oy"
commandText="INSERT INTO Sys_Logs (ID, Logger, Level, Host, Url , Method, Cookie, UserAgent, QueryString, Body , Message, CreateTime, IPAddress, Elapsed) VALUES (upper(uuid()), @Logger, @Level, @Host, @Url , @Method, @Cookie, @UserAgent, @QueryString, @Body , @Message, @CreateTime, @IPAddress, 0);">
<parameter name="@Logger" layout="${logger}" />
<parameter name="@Level" layout="${uppercase:${level}}" />
<parameter name="@Host" layout="${aspnet-request-host}" />
<parameter name="@Url" layout="${aspnet-request-url:IncludeScheme=false:IncludeHost=false}" />
<parameter name="@Method" layout="${aspnet-request-method}" />
<parameter name="@Cookie" layout="${aspnet-request-headers:HeaderNames=SYSTOKEN:ValuesOnly=true}" />
<parameter name="@UserAgent" layout="${aspnet-request-useragent}" />
<parameter name="@QueryString" layout="${aspnet-request-querystring:OutputFormat=JSON}" />
<parameter name="@Body" layout="${aspnet-request-posted-body}" />
<parameter name="@Message" layout="${message}" />
<parameter name="@CreateTime" layout="${longdate}" />
<parameter name="@IPAddress" layout="${aspnet-request-ip}" />
</target>
<target name="error" xsi:type="File" layout="**************************************************************************************************************************${newline} 日志时间 : ${longdate} ${newline} 日志来源 : ${logger} ${newline} 日志级别 : ${uppercase:${level}} ${newline} 日志内容 : ${message}${newline}" fileName="${basedir}/Logs/${date:format=yyyyMM}/ERROR-${shortdate}.log" />
<target name="debug" xsi:type="File" layout="**************************************************************************************************************************${newline} 日志时间 : ${longdate} ${newline} 日志来源 : ${logger} ${newline} 日志级别 : ${uppercase:${level}} ${newline} 日志内容 : ${message}${newline}" fileName="${basedir}/Logs/${date:format=yyyyMM}/DEBUG-${shortdate}.log" />
</targets>
<rules>
<!-- add your logging rules here -->
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
<!--Skip non-critical Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<logger name="*" level="Trace" writeTo="ApiTrace" />
<logger name="*" level="Info" writeTo="database" />
<logger name="*" level="Warn" writeTo="database" />
<logger name="*" level="Debug" writeTo="debug" />
<logger name="*" level="Error" writeTo="error" />
</rules>
</nlog>