sha*_*oth 5 iis web-config azure visual-studio-2010 azure-diagnostics
在我的web.config中,我有以下设置:
<system.diagnostics>
<trace>
<listeners>
<add name="AzureDiagnostics"
type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
Run Code Online (Sandbox Code Playgroud)
这是一样的,如MSDN例子在这里:
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener,
Microsoft.WindowsAzure.Diagnostics,
Version=1.0.0.0,
Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
Run Code Online (Sandbox Code Playgroud)
然而,Visual Studio将强调type内部属性<filter type="",当我移动鼠标时,它说the 'type' attribute is not allowed.如果我尝试使用智能感知找到什么是允许它提供lockItem,lockElements,lockAttributes,lockAllElementsExcept和lockAllAttributesExcept.
为什么Visual Studio不喜欢type内部filter?
Visual Studio使用模式验证配置文件中的XML.在这种情况下,它不会看到为架构中的filter元素定义的type属性.这可能只是架构中的疏忽/错误,因为过滤器配置的使用显然需要它,没有它就无法工作.这根本不是Windows Azure特有的.
如果打开app.config/web.config文件并检查属性窗口,您将看到Schemas属性.这些是用于验证配置文件的所有模式,有几个.这里感兴趣的模式是DotNetConfig.xsd(在我的机器上它使用VS 2012在C:\ Program Files(x86)\ Microsoft Visual Studio 11.0\xml\Schemas\1033\DotNetConfig.xsd下).如果您熟悉XSD,则可以将其打开,如果深入查看元素定义(configuration/system.diagnostics/trace/listeners/ListenerElement/filter),您将看到没有指示任何类型元素.但是,如果查看共享侦听器下的filter元素(configuration/system.diagnostics/sharedListeners/ListenerElement/filter),则属性类型存在且是必需的.
如果你使用下面的配置,你将看不到VS中的下划线,因为在共享侦听器部分的过滤器下预期类型.我再次指出,这里的下划线确实无关紧要,只是VS说它不认为你应该将type属性放在过滤器下面,但如果你想在跟踪下定义过滤器,显然需要它听众,只是架构中的一个错误.我不担心.
<system.diagnostics>
<sharedListeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</sharedListeners>
<trace>
<listeners>
<add name="AzureDiagnostics" />
</listeners>
</trace>
</system.diagnostics>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2442 次 |
| 最近记录: |