小编Kin*_*lay的帖子

ServiceConfiguration.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>
Run Code Online (Sandbox Code Playgroud)

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

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
    <listeners>
        <add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.CustomTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            type="OurSolution.Common.AzureDiagnosticTraceListener, Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
            name="AzureDiagnosticTraceListener" />
    </listeners>
    <formatters>
        <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, 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>
Run Code Online (Sandbox Code Playgroud)

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

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

.net logging enterprise-library azure

6
推荐指数
1
解决办法
952
查看次数

尝试删除时出现SQL异常错误#547和外键约束违规

我正在查看一些代码(我没有写它!)来测试我们的代码在尝试删除存在依赖项的表行时捕获了两个错误条件.

代码最初在消息中查找特定文本而不是使用错误号.

为了提供多语言支持,最好根据错误号而不是错误消息捕获异常.

在测试中,代码正在寻找两组文本,我似乎无法确定区别是什么,所以只是检查错误号547是不舒服的.

  1. DELETE语句与REFERENCE约束冲突...
  2. DELETE语句与SAME TABLE REFERENCE约束冲突...

假设两个错误消息的错误号都是547是否安全?干杯科林

sql-server

6
推荐指数
1
解决办法
4万
查看次数

标签 统计

.net ×1

azure ×1

enterprise-library ×1

logging ×1

sql-server ×1