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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:21:39+00:00 2026-05-11T04:21:39+00:00

We are using log4net and want to specify it’s configuration in an external config

  • 0

We are using log4net and want to specify it’s configuration in an external config file (as we have done with other sections). To do this we have changed the log4net section in the App.config to:

... <section name='log4net'       type='log4net.Config.Log4NetConfigurationSectionHandler, log4net'/> ... <log4net configSource='Log.config' /> ... 

And in the Log.Config file (same directory as the App.config) we have:

<log4net>   <appender name='General' type='log4net.Appender.FileAppender'>     <file value='myapp.log' />     <layout type='log4net.Layout.SimpleLayout' />   </appender>   <root>     <appender-ref ref='General' />   </root> </log4net> 

However, when we run the app, no log file is created (and no logging done). There are no error messages output to the console.

If we move the contents of the Log.config file back into the App.config (replacing the first code line above), it works as expected. Any idea why it is not working in an external file?

  • 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. 2026-05-11T04:21:40+00:00Added an answer on May 11, 2026 at 4:21 am

    Do you have the following attribute in your AssemblyInfo.cs file:

    [assembly: log4net.Config.XmlConfigurator(ConfigFile = 'Log4Net.config', Watch = true)] 

    and code like this at the start of each class that requires logging functionality:

    private static readonly ILog log =  LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 

    I have a blog post containing this and other info here.

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

Sidebar

Related Questions

i want log linenumber to my log file, using log4net.the config details of log4net
using CodeIgniter normally one has to specify the controllers in the config/routes.php file. This
I want log4net to write log files (using RollingFileAppender) to a subfolder of the
I'm using log4net to log write log message to a rolling log file. Now
We are currently using the log4net appender (web.config snippet): <appender name=FileAppender type=log4net.Appender.RollingFileAppender> Looking for
I know I can log exceptions to the database using Log4Net, but I want
I am using log4net 1.2.10.0. I have extended ILog and LogManager to include a
I have created a simple scenario using Log4net, but it seems that my log
I have a console app using log4net (via Castle Windsor). Everything logs fine to
I have noticed, by using log4net, that when calling ISession.Update, it updates all the

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.