Enterprise Library 6是否可以与Visual Studio 2013和/或2015一起使用? [英] Does Enterprise Library 6 work with Visual Studio 2013 and/or 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?
推荐答案
可以。您可以通过 Nuget 将 Enterprise 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.
- 从链接
- download Microsoft.Practices.EnterpriseLibrary.ConfigConsoleV6.vsix from the link
VSIX文件是使用开放包装约定的zip文件。
您可以将.VSIX扩展名重命名为.ZIP,并使用任何zip浏览器
(包括Windows File Explorer)来浏览其内容。
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 打开文件
- 定位
- extract the file into a folder
- locate the file called extension.vsixmanifest in the folder
- open the file with notepad.exe
- locate
<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
- 双击它。
- save the file and exit
- compress folder as a
ZIP
file again - rename the extension to
VSIX
- double click on it.
这篇关于Enterprise Library 6是否可以与Visual Studio 2013和/或2015一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!