You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Er...@idx.com on 2005/11/01 21:47:38 UTC

newbie - log4net deletes my config file!

I'm a .net and log4net newbie working thru the tutorial at 
http://www.codeproject.com/csharp/log4net_intro.asp

First example, logging to console with no config file, works fine. 2nd 
example, using a small config file, I see two problems.
The main problem is that my config file is deleted from the system when I 
run the project.  Here is the complete code of the project:
using System;
using log4net;

namespace log4netConsoleTest
{
        public class MainTestClass
        {
                private static  ILog logger = LogManager.GetLogger(typeof (MainTestClass));

        // constructor:
                static MainTestClass ()
                {
                        log4net.Config.XmlConfigurator.Configure();
                }
 
                static void Main(string[] args)
                {
                        logger.Debug("Here is a debug log.");
                        logger.Error("... and a non-fatal error.");
                        logger.Fatal("... and a fatal error.");
                }
        }
}
 
When I look into the file directory where the exe file lives, I see that 
file "log4netConsoleTest.exe.config' exists. When I run the project and 
stop at the 'LogManager.GetLogger' line, and then look again into the file 
directory, the config file is gone!   If I restore the file into the 
directory at that time, then the logging works as expected.

if I don't restore the file, log4net write this to the console:
"log4net:ERROR XmlConfigurator: Failed to find configuration section 
'log4net' in the application's .config file. Check your .config file for 
the <log4net> and <configSections> elements. The configuration section 
should look like: <section name="log4net" 
type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />"
I think that is also a problem. It apparently can't find the file (cause 
it doesn't exist), but instead of saying 'file not found', it says it 
can't find certain chars inside the file.  I'd like the error message to 
include the fully qualified name of where it looked for the file.

All help appreciated,
Erik Brooks


-----------------------------------------------
IMPORTANT NOTIFICATION
-----------------------------------------------
The contents of this e-mail and its attachments are confidential and may be privileged.  If you are not the intended recipient of this e-mail, please notify IDX immediately (by return e-mail to either the sender or security@idx.com), destroy all copies of this message along with any attachments and do not disclose, copy and/or distribute the contents.  The views expressed in this message are those of the author and not necessarily those of IDX.  In the absence of a prior written agreement with you authorizing commitments of IDX via e-mail, the above message shall not bind IDX, unless from a duly authorized officer of the company in a context indicating an intention to bind the company. 

This e-mail and its attachments are protected by copyright and other laws. (c) IDX Systems Corporation 2005.  All rights reserved.  IDX is a registered trademark of IDX Investment Corporation.