I have an ASP.Net MVC 5 application, it uses Ent Lib 6 Logging Application block.
Details:
- My web site is hosted on shared hosting server.
- We use Filezilla (FTP client) to publish and download files/logs.
- Log file is created on server
Problem:
When I try to download the log file form the server using FTP I get error stating "550 The process cannot access the file because it is being used by another process."
This is how my web.config looks
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<appSettings>
.....
</appSettings>
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
<add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="C:\ServerPath\Log\Log.txt" footer="" formatter="Text Formatter" header=""
rollFileExistsBehavior="Increment" rollInterval="Day" timeStampPattern="dd-MM-yyyy"
asynchronous="false" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="{timestamp(local:M/dd/yyyy HH:mm:ss.fff)} ({win32ThreadId}) ({severity}) {message}" name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
.....
</configuration>
As expected if I change my Web.config (on server) file lock is released and then I can download it or if I wait long enough then also lock is released. But of-course none of this is acceptable. So is it possible to get logs real time from the server? Other option could be to use some other logging library.