End*_*ono 6 logging system.diagnostics asp.net-mvc-3
我试图在我的ASP.NET MVC 3应用程序(vb.net)中使用Microsoft.VisualBasic.Logging.FileLogTraceListener.它在我的开发PC中工作,但从IIS 6服务器运行时抛出错误.这是我使用的web.config:
<?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>
Run Code Online (Sandbox Code Playgroud)
我得到的错误是这样的:
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()
Run Code Online (Sandbox Code Playgroud)
看起来像FileLogTraceListener试图写入C:\Documents and Settings\Default User\Application Data\Microsoft Corporation\Internet Information Services\6.0.3790.3959并失败.
实际上该文件夹Microsoft Corporation\Internet Information Services\6.0.3790.3959不存在Default User\Application Data.我尝试创建它,为每个人分配完全访问权限,但我仍然遇到同样的错误.
是否可以使用ASP.NET MVC应用程序中的Microsoft.VisualBasic.Logging.FileLogTraceListener?
非常抱歉,我的错误!
我C:\Documents and Settings\Default User\Application Data\Microsoft Corporation\Internet Information Services\6.0.3790.3959在不同的服务器上添加了。在我添加\Microsoft Corporation\Internet Information Services\6.0.3790.3959正确的服务器并授予对其写入访问权限后,日志记录可以正常工作。