gpt4 book ai didi

visual-studio-2013 - Enterprise Library 6 是否适用于 Visual Studio 2013 和/或 2015?

转载 作者:行者123 更新时间:2023-12-04 11:12:46 24 4
gpt4 key购买 nike

似乎没有,我们计划在 future 的项目中使用它(日志记录、异常等)。还支持吗?我没有看到像过去那样围绕此工具进行的大量事件。

我们已经有了 NewRelic,因此了解 NewRelic 是否已经可以进行日志记录/异常处理也很有帮助。例如,我可以创建自定义日志或异常并在新的遗物仪表板中查看它们吗?

最佳答案

确实如此。您可以通过 Nuget 将 Enterprise Library 6 添加到您的项目中这是示例应用程序。

using System;
using System.Diagnostics;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.Formatters;
using Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners;

namespace Practice.Logging
{
internal class Program
{
public static void Main(string[] args)
{
LoggingConfiguration loggingConfiguration = BuildProgrammaticConfig();
var defaultWriter = new LogWriter(loggingConfiguration);

// Check if logging is enabled before creating log entries.
if (defaultWriter.IsLoggingEnabled())
{
defaultWriter.Write("Log entry created using the simplest overload.");
defaultWriter.Write("Log entry with a single category.", "General");
defaultWriter.Write("Log entry with a category, priority, and event ID.", "General", 6, 9001);
defaultWriter.Write("Log entry with a category, priority, event ID, " + "and severity.", "General", 5, 9002, TraceEventType.Warning);
defaultWriter.Write("Log entry with a category, priority, event ID, " + "severity, and title.", "General", 8, 9003, TraceEventType.Warning, "Logging Block Examples");
}
else
{
Console.WriteLine("Logging is disabled in the configuration.");
}
}

private static LoggingConfiguration BuildProgrammaticConfig()
{
// Formatter
var formatter = new TextFormatter();

// Trace Listeners
var eventLog = new EventLog("Application", ".", "StackOverflow #24309323");
var eventLogTraceListener = new FormattedEventLogTraceListener(eventLog, formatter);

// Build Configuration
var config = new LoggingConfiguration();
config.AddLogSource("General", SourceLevels.All, true)
.AddTraceListener(eventLogTraceListener);

config.IsTracingEnabled = true;
return config;
}
}
}

您可以在 Logging Application Block 中找到更多详细信息

使用 Enterprise Library Configuration Console Extension

要将扩展安装到 Visual Studio 2013 中,您可以按照以下解决方法步骤操作。
  • link 下载 Microsoft.Practices.EnterpriseLibrary.ConfigConsoleV6.vsix

  • A VSIX file is a zip file that uses the Open Packaging Convention. You can rename the .VSIX extension to .ZIP and use any zip browser (including the Windows File Explorer) to browse its contents.


  • 将文件解压到文件夹
  • 找到名为 的文件extension.vsixmanifest 在文件夹
  • 用 notepad.exe 打开文件
  • 定位

  • <SupportedProducts>
    <VisualStudio Version="11.0">
    <Edition>Ultimate</Edition>
    <Edition>Premium</Edition>
    <Edition>Pro</Edition>
    </VisualStudio>
    </SupportedProducts>
  • 并将其替换为以下部分

  • <SupportedProducts>
    <VisualStudio Version="11.0">
    <Edition>Ultimate</Edition>
    <Edition>Premium</Edition>
    <Edition>Pro</Edition>
    </VisualStudio>
    <VisualStudio Version="12.0"> <!-- VS2013 -->
    <Edition>Ultimate</Edition>
    <Edition>Premium</Edition>
    <Edition>Pro</Edition>
    </VisualStudio>
    <VisualStudio Version="14.0"> <!-- VS2015 -->
    <Edition>Ultimate</Edition>
    <Edition>Premium</Edition>
    <Edition>Pro</Edition>
    </VisualStudio>
    </SupportedProducts>

    comparison
  • 保存文件并退出
  • 将文件夹压缩为 ZIP再次归档
  • 将扩展名重命名为 VSIX
  • 双击它。
  • 关于visual-studio-2013 - Enterprise Library 6 是否适用于 Visual Studio 2013 和/或 2015?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24309323/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com