I am trying to use Microsoft.VisualBasic.Logging.FileLogTraceListener in my ASP.NET MVC 3 app (vb.net). It works in my dev PC but throws an error when run from an IIS 6 server. Here is the web.config that I use:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="requests" switchValue="All">
<listeners>
<remove name="default" />
<add name="txtfile" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="txtfile" type="Microsoft.VisualBasic.Logging.FileLogTraceListener,
Microsoft.VisualBasic, Version=8.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL"
location="custom"
customlocation="D:\PROJECTS\saidproject\App_Data"
logfilecreationschedule="weekly"
/>
</sharedListeners>
</system.diagnostics>
</configuration>
The error that I got is this:
System.Configuration.ConfigurationErrorsException: Could not create Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL. ---> System.UnauthorizedAccessException: Access to the path 'C:\Documents and Settings\Default User\Application Data\Microsoft Corporation\Internet Information Services\6.0.3790.3959' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj)
at System.IO.Directory.CreateDirectory(String path)
at System.Windows.Forms.Application.GetDataPath(String basePath)
at System.Windows.Forms.Application.get_UserAppDataPath()
at Microsoft.VisualBasic.Logging.FileLogTraceListener..ctor(String name)
at Microsoft.VisualBasic.Logging.FileLogTraceListener..ctor()
Looks like FileLogTraceListener tried to write to C:\Documents and Settings\Default User\Application Data\Microsoft Corporation\Internet Information Services\6.0.3790.3959
and failed.
Actually the folder Microsoft Corporation\Internet Information Services\6.0.3790.3959
doesn't exist within Default User\Application Data
. I tried creating it, assigning full access to everyone, but I still got the same error.
Is it possible to use Microsoft.VisualBasic.Logging.FileLogTraceListener from ASP.NET MVC app?
So sorry all, my mistake!
I added C:\Documents and Settings\Default User\Application Data\Microsoft Corporation\Internet Information Services\6.0.3790.3959
on a different server. After I added \Microsoft Corporation\Internet Information Services\6.0.3790.3959
on the right server and granting write access to it, the logging works.
Your application is probably running in IIS 6 under an account that does not have enough access to the path that is trying to write. Try
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With