Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc ASP.NET MVC 2+;通用。日志记录+;NLog=为每个请求调用的会话启动_Asp.net Mvc_Logging_Asp.net Mvc 2_Nlog_Common.logging - Fatal编程技术网

Asp.net mvc ASP.NET MVC 2+;通用。日志记录+;NLog=为每个请求调用的会话启动

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

将日志库从log4net切换到我的ASP.NET之后,MVC 2应用程序保持正确的日志记录,但它开始为每个请求调用
HttpApplication.Session\u Start
方法

我正在尝试将NLog的
文件
目标与以下配置文件一起使用:

web.config

.
.
.
.
.
.
NLog.config

我已经尝试了以下方法:

  • 调试应用程序。
    ASP.NET\u SessionId
    cookie正在发送到服务器,并且
    Session.SessionId
    属性在请求之间不会更改
  • 切换回Common.Logging-log4net以验证问题是否与Common.Logging-NLog有关。它起作用了
  • 省略NLog配置文件的目标节点中的
    async=“true”
    属性以禁用NLog的异步包装器。它不起作用
  • 使用其他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}&#009;${uppercase:${level}}&#009;${callsite}&#009;${message}"/>
    </targets>
    <rules>
        <logger name="*" minlevel="Trace" writeTo="f" />
    </rules>
</nlog>