I am trying to enable archiving, but I'm getting an internal NLog exception when NLog attempts to move the log file to my archive directory. I am developing an ASP.NET application with VS2008.
Here is the exception:
2009-09-11 14:58:36.2201 Error Target exception: System.IO.IOException: The process cannot access the file because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.__Error.WinIOError()
at System.IO.File.Move(String sourceFileName, String destFileName)
at NLog.Targets.FileTarget.SequentialArchive(String fileName, String pattern)
at NLog.Targets.FileTarget.DoAutoArchive(String fileName, LogEventInfo ev)
at NLog.Targets.FileTarget.Write(LogEventInfo logEvent)
at NLog.LoggerImpl.Write(Type loggerType, TargetWithFilterChain targets, LogEventInfo logEvent, LogFactory factory)
Here is my (very basic) NLog config:
<nlog xmlns="
http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
internalLogFile="logs/log_nlogInternal.txt" >
<targets>
<target name="log_target_info" xsi:type="File"
layout="${longdate} | ${callsite} | ${level} | ${message}"
fileName="${basedir}/logs/log_info.txt"
archiveFileName="${basedir}/logs/archive/log_info.{#####}.txt"
archiveEvery="Minute"
archiveNumbering="Sequence"
concurrentWrites="false"
keepFileOpen="false"
/>
</targets>
<rules>
<logger name="*" minlevel="Trace" maxlevel="Info" writeTo="log_target_info" />
</rules>
</nlog>
In an ASP.NET environment, doesn't NLog "terminate" and close the file at some point before the page is rendered and the response is sent back to the browser? I don't have any other web apps running.
Any idea what's going on here?
Thanks.