7 Star 48 Fork 18

Meiam/Meiam.System

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
NLog-SQLServer.config 4.78 KB
一键复制 编辑 原始数据 按行查看 历史
Meiam 提交于 2023-06-26 09:50 . 修改文档
<?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="Microsoft.Data.SqlClient.SqlConnection, Microsoft.Data.SqlClient"
connectionString="Server=127.0.0.1;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 (newId(), @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="Microsoft.Data.SqlClient.SqlConnection, Microsoft.Data.SqlClient"
connectionString="Server=127.0.0.1;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 (newId(), @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>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/x91270/meiam.system.git
git@gitee.com:x91270/meiam.system.git
x91270
meiam.system
Meiam.System
master

搜索帮助