本文介绍了以编程方式覆盖WCF跟踪侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

阅读文章 WCF跟踪常见问题解答 WCF跟踪常见问题解答 [ ^ ]这是一个很好的介绍,但是我想重写在system.dianostics部分的配置文件中设置

如果我已在web.config/ap.config文件中配置了跟踪侦听器.我如何以编程方式覆盖这些.例如,如果我有

Read the article WCF Tracing FAQs WCF Tracing FAQs[^] which is a good introduction however I would like to override setting in my config file in system.dianostics section

If I have configured my trace listeners in my web.config/ap.config file. How can can I override these programmtically. For example if I have

<source propagateActivity="true" name="System.ServiceModel" switchValue="Off,ActivityTracing">
  <listeners>
    <add type="System.Diagnostics.DefaultTraceListener" name="Default">
      <filter type="" />
    </add>
    <add name="ServiceModelTraceListener">
      <filter type="" />
    </add>
  </listeners>
</source




我需要将switchValue更改为警告




and I need to change the switchValue to say warning

<source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
  <listeners>
    <add type="System.Diagnostics.DefaultTraceListener" name="Default">
      <filter type="" />
    </add>
    <add name="ServiceModelTraceListener">
      <filter type="" />
    </add>
  </listeners>
</source>



您可以简单地编辑适当的配置文件.
但是对于最终用户来说,他们不希望他们编辑这些文件.

希望从配置文件中建立这些值,然后在一个应用程序中选择一个选项
以编程方式更改这些设置,因此仅更改特定值(在这种情况下为switchValue).
人们通常不希望继续跟踪,但是如果用户遇到问题,则可以将激活跟踪设置为某种级别,然后通过电子邮件将跟踪日志发送回去进行分析.

所以请:
1.启动应用程序
2.应用程序读取配置文件设置.
3. [可选地,从单独的源(文件,数据库等)中读取用户首选项,并使用它们来覆盖配置文件设置]
4.提供选项供用户在应用程序运行时以编程方式覆盖某些设置.
5. [可选地,将用户替代首选项保留到另一个存储机制(文件,数据库等)]

一个人不想编辑或保留对原始配置文件的更改.如果需要持久更改,那么将有一个单独的具有替换的持久存储,并在处理原始配置文件后应用所有更改.但是在大多数情况下,只希望在应用程序运行时进行临时覆盖.

这可能吗?:confused:

根据我所做的研究,可以从配置文件中以编程方式 设置这些设置.似乎没有任何关于如何具有两者的 hybrid 的信息,使用配置文件来建立基本值,然后以编程方式覆盖一些. :sigh:



one can simply edit the appropriate config file.
However for end users one does not want them to edit these files.

What one would like is to have these values established from the config files and then have an option within one''s application
to alter these settings programmtically so only specific values (switchValue in this case) are changed.
One would normally not want tracing on but if a user has problems the user can set activate the trace to some level and then e-mail back the trace log for analysis.

So one would like:
1. Start application
2. Apllication reads in config file settings.
3. [Optionally read in user preferences from a separate source (file, database etc) and use these to override config file settings]
4. Provide the option for the user to programmtically override some settings while application is running.
5. [Optionally persist user override preferences to another storage mechanism (file, database etc)]

One does not want to edit or persist changes to the original config files. If one needs persist changes then one would have a separate persistant store with overrides and apply any changes after the original config file is processed. However for the most part one would only like a temporary override while the application is running.

Is this possible? :confused:

From what research I have done one can set up these settings programmatically or from a config file. There does not seem to be any information on how to have a hybrid of the two, use the config file to establish base values and then programmatically override some. :sigh:

推荐答案



这篇关于以编程方式覆盖WCF跟踪侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 19:56