Enterprise Library 6 是否适用于 Visual Studio 2013 和/或 2015? [英] Does Enterprise Library 6 work with Visual Studio 2013 and/or 2015?

查看:30
本文介绍了Enterprise Library 6 是否适用于 Visual Studio 2013 和/或 2015?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

It seems it does not and we are planning to use it (Logging, Exception, etc..) for future projects. Is it still supported? I do not see a lot of activity around this tool as there used to be.

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

We already have NewRelic so also be helpful to know if NewRelic can do logging/Exception handling already. For example, can I create custom logs or exceptions and see them in the new relic dashboard?

推荐答案

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

It does. You may add Enterprise Library 6 into your project via Nuget Here is the sample application.

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;
        }
    }
}

您可以在 中找到更多详细信息日志应用程序块

要将扩展安装到 Visual Studio 2013 中,您可以按照以下解决方法步骤操作.

To install the extension into the Visual Studio 2013 you may follow the workaround steps below.

VSIX 文件是使用开放打包约定的 zip 文件.您可以将 .VSIX 扩展名重命名为 .ZIP 并使用任何 zip 浏览器(包括 Windows 文件资源管理器)浏览其内容.

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>
      

      • 保存文件并退出
      • 再次将文件夹压缩为 ZIP 文件
      • 将扩展重命名为 VSIX
      • 双击它.

      这篇关于Enterprise Library 6 是否适用于 Visual Studio 2013 和/或 2015?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆