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

  • Home
  • SEARCH
  • 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 508939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:57:33+00:00 2026-05-13T06:57:33+00:00

I have a framework library which would do a lot of things including logging.

  • 0

I have a framework library which would do a lot of things including logging. We are using log4net for logging. This framework has the static logging class LogManager, a static instance of ILog (logger) and static methods for logging INFO, WARNING, DEBUG etc.

The static instance logger is getting initialized like this:

public static class LogManager
{        
    private static ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

    static ActivityLogManager()
    {

    }

    public static void LogDebugy(string message, params object[] messageParameters)
    {
        // Log the message here
    }
}

I have my own doubts if this is the right way to do it. I see from here that each class which needs to log, should declare a static instance of ILog.

Also I see that I would have to specify the Log4net config file in my framework project to log. Thought I read here that the config would get picked up from the executing assembly, but I don’t see it happen.

Is there any way that I can have my logging done from my framework class with the configuration getting picked up from my web application (for my web app) or some other business library project (for my business class libraries)?

I would also like to add some custom info into my log (like custom business object ID etc, application pool, ServerName, ClientHostName, ClientBrowser, ClientOS, Client User etc). Is it possible?

I am using AdoNetAppender.

Edit1: Am using log4net.Config.XmlConfigurator(ConfigFile = @"log4net.config", Watch = true) in my assembly.cs to point to log4net config file.

Edit2: My ILog Logger is in my framework LogManager Class, so only one instance is generated for my application.

  • 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-13T06:57:33+00:00Added an answer on May 13, 2026 at 6:57 am

    A lot of questions but about the first question, I use this style for the logger:

    private static ILog Log = LogManager.GetLogger(typeof(MyClass));
    

    Of course you can name the variable whatever you like, but this is recommended by the log4net team I think, as this results in only one ILog-instance per instance of your class.

    This is more or less what you are doing already so nothing to worry about there. I’m not sure why you are going the long way through the executing method though.

    I usually place the config in the Web.config or App.config. I couldn’t deduce if you use any of these for config. If you do use them it’s simple. You just add a configuration section for log4net and add the loggers, appenders and filters you need.

    If you want to log custom data you can either add it into the log-message, e.g:

    Log.WarnFormat(
        "Reactor malfunction, temperature {0} celsius."
        + "Evacuate sector {1} immediately", 
        temp, 
        sector);
    

    Or if the values needed are stored in some object, you can make a “renderer” for that type, which will custom print when the object is handed as a logging message, e.g Log.Warn(myObjWithCustomFormatting).

    A object renderer must derive from IObjectRenderer and register it in the configuration.

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

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.