Enterprise Library 5.0 Logging Step by Step Quick Start
Environment / Setup
- Visual Studio 2010 Professional
- Visual Studio Extension – NuGet Package Manager
- Visual Studio Extension – EnterpriseLibrary.Config
Step 1 – Create a console application.
Step 2 – Use NuGet package manager to add the Enterprise Library 5.0 logging assemblies to your project.
- Open the Package Manager Console
- Set the package manager default project to your console application.
- Issue the following package manager command:
PM> install-package EnterpriseLibrary.Logging
Step 3 – Add an application configuration item (App.config) to your console application.
Step 4 – Configure Enterprise Library 5.0 logging.
- Launch the Enterprise Library configuration editor.
- Click BlocksàAdd Logging Settings
- Save and exit.
Step 5 – Code a log entry.
var logEntry = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry();
logEntry.Message = "test log entry 1";
Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEntry);
Step 6 – Try it out.
- Run the application.
- Run eventvwr.exe
No comments:
Post a Comment