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 6357153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:06:39+00:00 2026-05-24T23:06:39+00:00

Browsing the nuget library, i came across Ninject.Extensions.Logging.nlog2 . Some googling and trying to

  • 0

Browsing the nuget library, i came across Ninject.Extensions.Logging.nlog2. Some googling and trying to figure things out, I can’t seem to find how or why you would use this extension.

Is it advisable to use with MVC 3?

What exactly is the point?

How do you use it?

  • 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-24T23:06:39+00:00Added an answer on May 24, 2026 at 11:06 pm

    It’s really very simple; both NLog and log4net expect you to use singleton/static references to obtain logger instances:

    private static Logger logger = LogManager.GetCurrentClassLogger();
    

    This is widely considered to be an anti-pattern, but even if you have no problem with it, it’s still going against the grain if you’re trying to implement dependency injection. In the case of NLog it’s not even an ILog or ILogger interface like log4net, it’s an actual class. That carries certain disadvantages such as the inability to create proxies, deferred loading, caching, etc.

    What the Ninject.Extensions.Logging project does is first provide an abstract ILogger class with simple methods like Info, Error, etc., so you can inject it as a dependency and switch the logging framework if you want:

    public class WidgetProvider
    {
        private readonly ILogger log;
    
        public WidgetProvider(ILogger log)
        {
            this.log = log;
        }
    }
    

    This is how DI is supposed to work – a class never goes out to grab its own dependencies, instead they’re supplied by the constructor or caller as above. Assuming you’ve already integrated Ninject itself into your project, that’s really all you have to do, there is no additional work.

    As for what Ninject.Extensions.Logging.NLog2 does specifically – it just provides an implementation for Ninject.Extensions.Logging based on NLog2. The base Logging library doesn’t actually contain any implementations of ILogger, you have to plug in one of the specific libraries (NLog, NLog2, or log4net) in order to get it to work.

    If you switch your DI library more often than you switch loggers then don’t bother with it. But if you’re like me and use Ninject in almost every project, then it’s a nice way to decouple your code from any specific logging library.

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

Sidebar

Related Questions

While browsing some source code I came across a function like this: void someFunction(char
Browsing the code sample from C# 4.0 in a nutshell I came across some
While browsing some web service docs, I came across the word payload , xml
While browsing some code, I came across this line: if False: #shedskin I understand
While browsing I came across this blog post about using the Wikipedia API from
While browsing the code of an erlang application, I came across an interesting design
Browsing through the source of a spring framework project i came across a method
I was just browsing the perldocs when I came across this in an example
While browsing the Caml Light library for programming examples, I stumbled across the following
while browsing through a queue examples, I came across http://login2win.blogspot.in/2008/07/c-queues.html Its a queue example

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.