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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:16:29+00:00 2026-05-24T18:16:29+00:00

There are two ways of configuring and using log4net. First one is when I

  • 0

There are two ways of configuring and using log4net. First one is when I can configure my own appender and associated logger:

<!-- language: xml -->

<appender name="myLogAppender" type="log4net.Appender.RollingFileAppender" >
    <file value="Logs\myLog.log" />
    <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %level - %message%n" />
    </layout>
</appender>

<logger name="myLog">
    <level value="All"></level>
    <appender-ref ref="myLogAppender" />
</logger>

And then when I want to write something in log, I can do the following:

ILog log = LogManager.GetLogger("myLog");
log.Info("message");

Another way to use it is to configure root to be as detailed as I want:

<!-- language: xml -->

<root>
    <level value="Error" />
    <appender-ref ref="myLogAppender" />
</root>

And in this case I can log messages like this:

ILog log = LogManager.GetLogger(typeof(Bar));
log.Info("message");

The benefits of second approach is that you can enable or disable some messages on the fly. But the problem is that I’m developing in EPiServer CMS and it has its own logging system that uses log4net and if I enable info logging at root level, then a lot of system logs will be written.

How do you use log4net? Each part of a system writes in its own logger, or everything is written in default logger, and configuration decides what to do next?

  • 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-24T18:16:30+00:00Added an answer on May 24, 2026 at 6:16 pm

    Regarding how you log messages within code, I would opt for the second approach:

    ILog log = LogManager.GetLogger(typeof(Bar));
    log.Info("message");
    

    Where messages sent to the log above will be ‘named’ using the fully-qualifed type Bar, e.g.

    MyNamespace.Foo.Bar [INFO] message
    

    The advantage of this approach is that it is the de-facto standard for organising logging, it also allows you to filter your log messages by namespace. For example, you can specify that you want to log INFO level message, but raise the logging level for Bar specifically to DEBUG:

    <log4net>
        <!-- appenders go here -->
        <root>
            <level value="INFO" />
            <appender-ref ref="myLogAppender" />
        </root>
    
        <logger name="MyNamespace.Foo.Bar">
            <level value="DEBUG" />
        </logger>
    </log4net>
    

    The ability to filter your logging via name is a powerful feature of log4net, if you simply log all your messages to "myLog", you loose much of this power!

    Regarding the EPiServer CMS, you should be able to use the above approach to specify a different logging level for the CMS and your own code.

    For further reading, here is a codeproject article I wrote on logging:

    • The Art Of Logging
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are two ways to implement overloads. The first one is to do everything
Alright there's two ways this can go. One is from the presentation side, and
There are two ways in which I can easily make a key,value attribution in
Let's say there are two ways to define a function: First way: Bar.prototype.foo =
I know there are two ways of making a copy of a database. One
As far as I can see there are two ways, both with their drawbacks.
In C++, i know there are two ways to overload. We can overload it
It seems there are two ways to build queries -- either using query expressions:
I have an asp.net dropdownlist control. There are two ways it can be selected.
There are two ways, that I can think of, to obtain similar results from

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.