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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:19:07+00:00 2026-06-13T12:19:07+00:00

I have been working on getting log4net working in a demo program for a

  • 0

I have been working on getting log4net working in a demo program for a client so they can integrate it with their code base. I found this article when doing the implementation http://www.codeproject.com/Articles/14819/How-to-use-log4net, and
one of the steps described is

Step 2: Add below line in your AssemblyInfo.cs file.

[assembly: log4net.Config.XmlConfigurator(ConfigFile="Web.config", Watch=true)]   //For log4net 1.2.10.0

and as soon as I added that line of code to my AssemblyInfo.cs the logger started working.

I did some Googling around the place to try to understand why this line is required, and most documentation and comments claimed AssemblyInfo is for optional configuration information. I don’t understand why adding this line would have made my program work;
my key questions are
– how does the configuration information in AssemblyInfo.cs get picked up and used (and is there some documentation that describes this clearly)
– how did log4net “know” to pick up that information from AssemblyInfo.cs?

I understand from What does the assembly keyword mean in the AssemblyInfo.cs. Does it permit to use method inside? that these are attributes on the assembly but not the mechanism behind 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-06-13T12:19:07+00:00Added an answer on June 13, 2026 at 12:19 pm

    Nice topic. I cannot provide a link, as you are asking, only few points, findings. Some of my statements could be known and obvious. I am trying to put them together here, in one place. And give the answer how that magic with log4Net setting is triggered.

    • AssemblyInfo.cs is a “normal” file, as any other .cs file, containing e.g. C# class definition. In a project file it is marked as “compile”.
      Other words, this is a place chosen by convention, where all “assembly” attributes should be placed. But they could be (but should not) anywhere (if placed outside of a specific namespace declaration in any of project compiled files).
    • Any custom attribute, like log4Net “XmlConfiguratorAttribute” could be added to assembly definition, if marked as [AttributeUsage(AttributeTargets.Assembly)].
    • All attributes are just a meta information. Other words they are available (for reflection), but not used implicitly. Not executed by default.
    • (some Attributes like AssemblyVersion, AssemblyTitle seem to be executed, but it is intended and explicit call mad by compiler)

    Given this, what we can do with attributes. Our (custom) code is allowed to use reflection to check if there is an Attribute, mostly of a specific known type (e.g. XmlConfiguratorAttribute). If such Attribute exists, we can “execute” it. For example. I am using ASP.NET MVC having its “runtime” which grants that any Attribute of a type IFilter will be executed properly. It is the MVC runtime, observing classes and methods and explicitly executing these Attributes.

    The solely stated attribute declaration inside of the AssemblyInfo.cs is not enough. As in the snippet above where XmlConfiguration is declared. Usally there will be some other call (in ASP.NET maybe in Global.asax) constructing the ILog

    ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
    

    Well, and somewhere in the flow of methods call-chain, inside of the Log4Net will be a check if exists:

    var attributes = Attribute.GetCustomAttributes(thisAssembly, typeof(XmlConfiguratorAttribute));
    

    and if yes (assembly has such attribute) – log4Net can use it, force it to do its job (e.g. configure itself from xml)

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

Sidebar

Related Questions

I have been working on a quick WinForms program. I found this SO question
I have been working on getting this seat mapping chart for a while and
I have been working on getting a mail app to work from a tutorial
I have been working on getting my OSGi application to run outside eclipse. It
I have been working on getting a basic ATL project to compile in Visual
So I have been working on getting this Twitter Bootstrap typeahead to work and
I have been working on a project in scala, but I am getting some
I have been working on this thing for client broker server system but i
I have been working on getting a python CGI script to work all day,
So I have been working on getting a small (> 1 MB) video to

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.