Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3425978
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:39:32+00:00 2026-05-18T06:39:32+00:00

Using the snippet below which uses NLog how can this be done using Enterprise

  • 0

Using the snippet below which uses NLog how can this be done using Enterprise Library 5.0 Logging?

    private Logger _logger;
    public NLogger() {            
        _logger = LogManager.GetCurrentClassLogger();
    }

    public void Info(string message) {
        _logger.Info(message);
    }

    public void Warn(string message) {
        _logger.Warn(message);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:39:32+00:00Added an answer on May 18, 2026 at 6:39 am

    You are looking for something like this:

    private LogWriter _logger;
    public void EntLibLogger()
    {
        _logger = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>(); ;
    }
    
    public void Info(string message)
    {
        LogEntry log = new LogEntry();
        log.Message = message;
        log.Categories.Add("Information");
        log.Priority = Priority.Normal;
        log.Severity = TraceEventType.Information;
        _logger.Write(log);
    }
    
    public void Warn(string message)
    {
        LogEntry log = new LogEntry();
        log.Message = message;
        log.Categories.Add("Warning");
        log.Priority = Priority.High;
        log.Severity = TraceEventType.Warning;
        _logger.Write(log);
    }
    
    public void Error(string message, int EventID, Dictionary<String,String> dictMessage)
    {
        LogEntry log = new LogEntry();
        log.Message = message;
        log.Categories.Add("Error");
        log.Priority = Priority.Highest;
        log.Severity = TraceEventType.Error;
        log.EventId = EventID;
        _logger.Write(log, dictMessage);
    }
    

    Setting up the configuration settings in app.config is the fiddly bit.

    My recommendation is to make EventID globally unique per call (system documentation always includes the spreadsheet with these numbers and the project/file/line# these occur at). This way, if the app is in production, it is extremely likely that you’ll get 1 row from the log and you’ll have to be able to identify where in the source this logging call came from. I usually add a dictionary of stuff for local variables and their values for debugging purposes. One place wants the previous values logged, so the audit events always include a dictionary.

    The way it logs by default in the database, Entlib stores “category” as a string in both the categories and log table. Severity, priority and EventID are stored as ints. FormattedMessage is a large clump of stuff that is defined in the formatters section, and also includes the contents (the key value pairs) of dictionaries – if used.

    Categories is a collection because there may be some times you want to log everything in the database, but certain messages also write to the event log and/or send the dev a text message to get their fanny perpendicular in to work asap. One place I worked at used an Iridium pager to let the designated person know that the servers were down/in trouble, since they liked mountain climbing, they were frequently where no cell coverage existed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the code snippet below, however it's not working quite as I
Consider the following snippet: using System; using System.Collections.Generic; using System.Linq; using System.Net; namespace ForumLogins
using the Code Snippet for sending email in VB.Net I have successfully sent an
Using the obsolete System.Web.Mail sending email works fine, here's the code snippet: Public Shared
In the following snippet, using XmlReader, when I encounter an element. I would like
We are currently using the log4net appender (web.config snippet): <appender name=FileAppender type=log4net.Appender.RollingFileAppender> Looking for
What's wrong with the following snippet ? #include <tr1/functional> #include <functional> #include <iostream> using
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using online interfaces to a version control system is a nice way to have
Using ASP.NET MVC there are situations (such as form submission) that may require a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.