使用 elmah 的外部配置文件
我正在使用 elmah (v1.1.11517.0) 并尝试将配置移动到外部源。
我的配置目前看起来像这样:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah"/>
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah"/>
<section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah"/>
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net configSource="Settings\RobDev\log4net.config" />
<elmah configSource="Settings\RobDev\ELMAH.config" />
</configuration>
log4net 很高兴并且运行良好,但是对于 elmah 我收到错误
Parser Error Message: The attribute 'configSource' cannot be specified because its name starts with the reserved prefix 'config' or 'lock'.
这是一个痛苦,elmah 文件肯定在那里,但有些东西不高兴。
可能是什么原因造成的?
I am using elmah (v1.1.11517.0) and am trying to move the config to an external source.
My config currently looks like this:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah"/>
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah"/>
<section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah"/>
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net configSource="Settings\RobDev\log4net.config" />
<elmah configSource="Settings\RobDev\ELMAH.config" />
</configuration>
log4net is happy and runs fine, however for elmah I get the error
Parser Error Message: The attribute 'configSource' cannot be specified because its name starts with the reserved prefix 'config' or 'lock'.
Which is a pain, the elmah file is definitely there, but something isn't happy.
What might be causing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不能对 elmah 使用 configSource 元素的原因是因为 elmah 被定义为一个sectionGroup。您可以在部分上使用 configSource。这就是它在 log4net 上运行的原因。
如果您像 Dan Atkinson 一样需要单独的 Web 部署配置文件,您可以执行以下操作:
缺点是每个部分都需要一个配置文件。但您经常在 Web 部署项目中这样做。
The reason why you can't use the configSource element for elmah is because elmah is defined as a sectionGroup. You can use the configSource on Sections. That is why it works on log4net.
If you need the seperate config-file for web-deployment like Dan Atkinson you could do the following:
The downside is that you need a config file for each section. But you often do that for web deployment projects.
我已经为这个问题添加了赏金,因为我也想知道这个问题的答案。
我需要它,因为我使用 Web 部署功能,该功能通过文件的 configSource 属性替换文件。
同时,您可以将 elmah.config 的内容移至 web.config 中,替换
。I've added a bounty to this question as I'd also like to know the answer to this.
I need it because I use Web Deployment functionality which replaces files by their configSource attribute.
In the meantime, you could move the contents of elmah.config into your web.config, replacing the
<elmah configSource="..." />
.