加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

.net – ServiceConfiguration.cscfg中的自定义/嵌套XML设置

发布时间:2020-12-16 00:00:13 所属栏目:百科 来源:网络整理
导读:我们正在尝试将一些动态可配置的日志记录实现到我们的Azure应用程序中,并且我们正在使用企业库来完成这项工作,但是为了实现这一点而需要的xml比ServiceConfiguration的简单“appSetting”样式设置更复杂. .cscfg文件似乎接受,因为它需要嵌套的xml节点, 例如
我们正在尝试将一些动态可配置的日志记录实现到我们的Azure应用程序中,并且我们正在使用企业库来完成这项工作,但是为了实现这一点而需要的xml比ServiceConfiguration的简单“appSetting”样式设置更复杂. .cscfg文件似乎接受,因为它需要嵌套的xml节点,

例如

<configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,Microsoft.Practices.EnterpriseLibrary.Logging,Version=5.0.414.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>

解决了(请原谅这个窗口中的格式):

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
    <listeners>
        <add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData,PublicKeyToken=31bf3856ad364e35"
            type="OurSolution.Common.AzureDiagnosticTraceListener,Common,Version=1.0.0.0,PublicKeyToken=null"
            name="AzureDiagnosticTraceListener" />
    </listeners>
    <formatters>
        <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter,PublicKeyToken=31bf3856ad364e35"
            template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
            name="Text Formatter" />
    </formatters>
    <categorySources>
        <add switchValue="All" name="General">
            <listeners>
                <add name="AzureDiagnosticTraceListener" />
            </listeners>
        </add>
    </categorySources>
</loggingConfiguration>

我看不到愚弄ServiceDefinition或ServiceConfiguration文件来接受这个的方法,尽管我可以看到一种方法告诉企业库使用我可以在app.config中执行的ServiceConfiguration文件.

为什么我们试图解决这个问题是为了允许我们动态调整日志记录的设置,即从No logging更改为Verbose而不必进行重新部署,这在我们的实时应用程序中证明是耗时且不切实际的住,所以可能还有奇怪的虫子;-)

任何想法都会非常感激
问候
Kindo Malay

其他选择:

>任意配置的Base64编码,并将它们放入cscfg的值>(我最喜欢的)只需在blob存储或数据库中保留额外的配置(使管理部署的生活更简单)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读