After switching the logging library behind Common.Logging 2.1.1 from log4net to NLog 2.0 my ASP.NET MVC 2 application kept logging correctly, but it started calling the HttpApplication.Session_Start
method for each request.
I'm trying to use NLog's File
target with the following configuration files:
web.config
<?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>
NLog.config
<?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>
I have already tried the following:
- Debugging the application. The
ASP.NET_SessionId
cookie is being sent to the server and theSession.SessionID
property is not changing between requests. - Switching back to Common.Logging - log4net to verify that the problem is related to Common.Logging - NLog. It works.
- Omitting the
async="true"
attribute in the targets node of the configuration file of NLog to disable the AsyncWrapper of NLog. It doesn't work. - Using other NLog targets, tried
Debugger
andDatabase
. It works.
I need to hold to the File
target and I'd like to use NLog.