Asp.net mvc ASP.NET MVC 2+;通用。日志记录+;NLog=为每个请求调用的会话启动
将日志库从log4net切换到我的ASP.NET之后,MVC 2应用程序保持正确的日志记录,但它开始为每个请求调用Asp.net mvc ASP.NET MVC 2+;通用。日志记录+;NLog=为每个请求调用的会话启动,asp.net-mvc,logging,asp.net-mvc-2,nlog,common.logging,Asp.net Mvc,Logging,Asp.net Mvc 2,Nlog,Common.logging,将日志库从log4net切换到我的ASP.NET之后,MVC 2应用程序保持正确的日志记录,但它开始为每个请求调用HttpApplication.Session\u Start方法 我正在尝试将NLog的文件目标与以下配置文件一起使用: web.config . . . . . . NLog.config 我已经尝试了以下方法: 调试应用程序。ASP.NET\u SessionIdcookie正在发送到服务器,并且Session.SessionId属性在请求之间不会更改 切换回Comm
HttpApplication.Session\u Start
方法
我正在尝试将NLog的文件
目标与以下配置文件一起使用:
web.config
.
.
.
.
.
.
NLog.config
我已经尝试了以下方法:
- 调试应用程序。
cookie正在发送到服务器,并且ASP.NET\u SessionId
属性在请求之间不会更改Session.SessionId
- 切换回Common.Logging-log4net以验证问题是否与Common.Logging-NLog有关。它起作用了
- 省略NLog配置文件的目标节点中的
属性以禁用NLog的异步包装器。它不起作用async=“true”
- 使用其他NLog目标,尝试了
和调试器
。它起作用了数据库
文件
目标,我想使用NLog
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="common">
<section
name="logging"
type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
.
.
.
<configSections>
.
.
.
<common>
<logging>
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20">
<arg key="configType" value="FILE" />
<arg key="configFile" value="~/NLog.config" />
</factoryAdapter>
</logging>
</common>
</configuration>
<?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">
<!--
See http://nlog-project.org/wiki/Configuration_file
for information on customizing logging rules and outputs.
-->
<targets async="true">
<target
name="f"
xsi:type="File"
fileName="${basedir}/bin/statistics/logs/${shortdate}.log"
layout="${longdate}	${uppercase:${level}}	${callsite}	${message}"/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="f" />
</rules>
</nlog>