15

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.

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?

cilerler
  • 9,010
  • 10
  • 56
  • 91
punkouter
  • 5,170
  • 15
  • 71
  • 116

6 Answers6

33

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

You may find more details in Logging Application Block

To use Enterprise Library Configuration Console Extension

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

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.

  • 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>
  • and replace it with the part below
<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

  • save the file and exit
  • compress folder as a ZIP file again
  • rename the extension to VSIX
  • double click on it.
cilerler
  • 9,010
  • 10
  • 56
  • 91
  • Ok. I installed it in VS2013. How do I access the Config generator from there? In your sample where are the log files being written to exactly ? Is there a reference on setting up the tools programmatically as well as using the config tool somewhere? – punkouter Jun 23 '14 at 19:41
  • Please confirm that you have **EnterpriseLibrary.Config.v6** in **Tools** + **Extension and Updates** + **Installed** + **All** if you have it, locate the **App.config** under your project and right click on it. You will see **Edit configuration file v6**, click on it. – cilerler Jun 23 '14 at 21:47
  • 1
    The visual studio 2013 work around wont work with Enterprise Library 6 – PSR Nov 07 '14 at 14:37
  • @Sree can you be more specific please? I'm using it. – cilerler Nov 07 '14 at 14:40
  • @cilerler I followed the steps you specified. When I right click on app config file->Edit configuration file I am getting this error "Error launching the configuration console Could not locate the Enterprise Library binaries required to launch the configuration console. Either use NuGet to add references to the Enterprise Library blocks or set a value for the 'Enterprise Library binaries paths' property on the solution to indicate the location of the binaries." – PSR Nov 10 '14 at 06:24
  • @Sree, cilerler, would you kindly check whether the new extensions, mentioned in a new answer, solve your issues? Thank you! – Deilan Nov 11 '14 at 19:40
  • @Sree The project you are trying to edit doesn't have Enterprise Library's assemblies. You must install those via Nuget then you may edit app.config via right click. Let me know if you need further instructions please. – cilerler Nov 11 '14 at 20:29
  • @Deilan If you compare the VSIX file that you mention, is exactly same as what I described here. – cilerler Nov 11 '14 at 20:34
  • @cilerler, 1) Your link leads to a page for download Microsoft Enterprise Library 6 package, not Microsoft.Practices.EnterpriseLibrary.ConfigConsoleV6.vsix. After extraction of the downloaded package by the link there is no such file. 2) I just mentioned EnterpriseLibrary.Config extension in the start of my answer. The real proposed solution is at the end, and it leads to the external resource, that contains links to download. 3) Whether the names may seem similar, the files are actually binary different and you could check it by yourself. So please read & try again carefully. Thanks. – Deilan Nov 11 '14 at 20:57
  • @Deilan **1)** You are right, but it is not my fault. It was correct when I posted the answer. I'm updating the links right now. (In the mean time, when you see that kind of changes you may/should edit too) And also, that is the reason why we aren't depending on links here and providing actual information. **2)** I saw your solution and downloaded that to see what is different than here **3)** I'm not replying without reading my friend, if you download the file in that site and compare the package via BeyondCompare etc. you will see that it, is exactly done the same thing what I described here – cilerler Nov 11 '14 at 23:33
  • @cilerler, ok, let's go do it step-by-step then. 1) Download '[Microsoft.Practices.EnterpriseLibrary.ConfigConsole.vsix](http://bit.ly/1xgJAFX)', change ext to .zip and unpack, calc MD5 of unpacked `Microsoft.Practices.EnterpriseLibrary.ToolLauncher.Core.dll` file. Result - '**1CE922...**'. 2) Download '[Microsoft.Practices.EnterpriseLibrary.ConfigConsole.V5.VS2013.vsix](http://bit.ly/1xwE0Ok)', change ext, unpack and calc MD5 of the same file - '**4E48FF...**'. 3) Repeat with '[Microsoft.Practices.EnterpriseLibrary.ConfigConsoleV6.2013.vsix](http://bit.ly/1xwE0Ok)' - '**E9CE32...**'. – Deilan Nov 12 '14 at 09:09
  • @Deilan lets put this case into rest :) First I returned the links to original sources then corrected the direct link one. It is now points to http://download.microsoft.com/download/B/B/4/BB4234FA-F238-4BDE-8A63-FFB6B2D81761/Microsoft.Practices.EnterpriseLibrary.ConfigConsoleV6.vsix which is Microsoft's original location. Also, even from the original links if you click on Download button you will have a menu that you may select the VSIX package. Please download the package, apply the changes I explained above and let me know if they are not EXACTLY same as the one your link provides ;) – cilerler Nov 12 '14 at 14:19
  • @cilerler, standing ovation. :) After a couple of modifications you've achieved your goal and now your link actually lead where you expect it to lead. And no, "if I click on Download button I have not a menu that I may select the VSIX package" just because even after your previous modification your link was wrong. ;) It led straight to download of EnterpriseLibrary6-binaries.exe without main page load and obviously without selection menu, that you mentioned. Here is the correct [link](http://www.microsoft.com/en-us/download/details.aspx?id=38789) (with menu). – Deilan Nov 12 '14 at 17:56
  • @cilerler, and yes, thanks to you, now I realize, that proposition of a shorter and faster but similar solution of a problem is a serious argument for a downvote. :) Have a nice weekend! – Deilan Nov 12 '14 at 17:57
  • @Deilan links were correct until you complaint about them and the reason I kept changing the links because I valued your comment and updated without proper research. When you continue to complain I researched properly and saw that it was a false alarm so reversed it back to what it was. (you may confirm it from the edit logs) Please respect the time I spent here to provide the "actual solution" in depth. You are free to provide any solution and anyone is free to down or up vote. This platform is not for fighting but help each other – cilerler Nov 12 '14 at 17:57
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/64825/discussion-between-cilerler-and-deilan). – cilerler Nov 12 '14 at 23:44
  • works perfekt... you only have to install the Enterprise Library itself - eg via NuGet: `Install-Package EnterpriseLibrary.Logging` – Gerwald Jun 15 '15 at 12:57
  • Note this install can also be run if you are having problems with VS 2017 by adding: Ultimate Premium Pro – InquisitionX Jan 24 '18 at 19:35
  • @cilerler What about Visual Studio 2019? (_I tried 16.0 and 17.0 but doesn't work_) – Mehdi Dehghani Apr 04 '19 at 07:51
  • @MehdiDehghani `16` should work, not sure what it could be the problem. Just locate a VSIX extension from the hub that works. Extract the file and determine the value from it. – cilerler Apr 04 '19 at 11:24
  • Thanks for the reply, Seems like there is no need to this entry anymore (_at least in specific extension that I'm working on it_), I followed [How to upgrade extensions to support Visual Studio 2019](https://devblogs.microsoft.com/visualstudio/how-to-upgrade-extensions-to-support-visual-studio-2019/) – Mehdi Dehghani Apr 04 '19 at 11:33
19

Technically the same as @cilerler suggests, but ready-to-download-and-use solution.

Visual Studio 2013: Microsoft.Practices.EnterpriseLibrary.ConfigConsole.V6.VS2013.vsix (Source) Visual Studio 2015: Microsoft.Practices.EnterpriseLibrary.ConfigConsole.V6.VS2015.vsix (Source)

Deilan
  • 4,740
  • 3
  • 39
  • 52
0

We need these following dlls in the bin folder of the asp.net or console or windows app

•Microsoft.Practices.EnterpriseLibrary.Common.dll
•Microsoft.Practices.EnterpriseLibrary.Configuration.DesignTime.dll
•Microsoft.Practices.EnterpriseLibrary.Configuration.Design.HostAdapterV5.dll
•Microsoft.Practices.EnterpriseLibrary.Configuration.EnvironmentalOverrides.dll

Practically Microsoft.Practices.Unity.dll is optional is what I see for entlib 6

source from entlib 5 msdn

Furkan Ekinci
  • 2,472
  • 3
  • 29
  • 39
Sundara Prabu
  • 2,361
  • 1
  • 21
  • 20
0

Yes it does. This link will provide all the neccessary details https://msdn.microsoft.com/en-us/library/dn169621.aspx

Also you can refer below sites for detailed implementations. You can install vsix version or binaries (http://www.microsoft.com/en-us/download/details.aspx?id=38789) to create configs. vsix sometimes does not work so you can modify extension.vsixmanifest as stated in below post.

http://www.gonetdotnet.info/posts/configure-and-use-enterprise-library-5-logging http://www.gonetdotnet.info/posts/how-to-configure-and-use-enterprise-library-5-0-application-blocks-using-nuget-package-manager

Nilesh Sawant
  • 1,406
  • 14
  • 8
0

The project I have is using Enterprise Library 6.0, while the VSIX seems to target EL 5. While I have not been able to get VSIX to work correctly in Visual Studio 2013 and 2015, I am able to get the Enterprise Library 6 Configuration tool from the binaries provided by Microsoft. Here is a link to the download.

Select EnterpriseLibrary6-binaries.exe. Install it by unzipping the file to a folder. The 64-bit Enterprise Library Configuration tool named EntLibConfig.exe. There is a 32-bit version named EntLibConfig-32.exe as well.

Chris Voon
  • 1,974
  • 2
  • 18
  • 11
0

For Visual Studio 2017.

<VisualStudio Version="15.0"> <!-- VS2017 -->
    <Edition>Enterprise</Edition>
    <Edition>Premium</Edition>
    <Edition>Pro</Edition>
</VisualStudio>
Aykut ÇALIŞKAN
  • 408
  • 4
  • 12