Hi there,

I'm using log4net version 1.1.1 in a .dll assembly using VB.NET. I'm simply
trying to get a ConsoleAppender to work with my configuration file. For some
reason, if I have the log4net configuration information in its own .config
file, log4net seems to read it properly. If, however, I have it included
with other configuration information in the same file, it doesn't read it
and no logging occurs. I assume this is possible because the log4net site
says:

"The configuration is read from the log4net element in the file. Only one
log4net element can be specified in the file but it may be located anywhere
in the XML hierarchy."

Some details: My class is called NAMEndpoint. I have my class configuring
log4net as follows:

Private Shared ReadOnly mobjLogMgr As ILog =
LogManager.GetLogger(GetType(NAMEndpoint))

In the New method of this class:

DOMConfigurator.Configure(New System.IO.FileInfo(strConfigPath))

Where strConfigPath is the path of the configuration file. My own custom
code is correctly reading this file using the same variable so I'm sure the
file path is correct and valid.

My configuration file looks like:

<?xml version="1.0" ?>
<NAMEndpoint>
        <log4net debug="true">
                <appender name="ConsoleAppender"
type="log4net.Appender.ConsoleAppender" >
                        <layout type="log4net.Layout.PatternLayout">
                                <conversionPattern value="%date [%thread]
%-5level %logger [%ndc] - %message%newline" />
                        </layout>
                </appender>
                <root>
                        <level value="DEBUG" />
                        <appender-ref ref="ConsoleAppender" />
                </root>
        </log4net>
        <systemID>1</systemID>
        <filePath>Z:\Datafaction Phase II\New Messages from NAM
Website</filePath>
</NAMEndpoint>

The SystemID and filePath elements at the bottom are separate configurations
I've set up.

If I take the <log4net> node out of this file and put it in its own file, it
seems to work OK, and the internal debugging information gets generated. But
with the file the way it is above, I get no errors when calling
DOMConfigurator.Configure, but when I try and log a message I get:

log4net:ERROR No appenders could be found for category
(LoringWard.Integration.NAMEndpoint).
log4net:ERROR Please initialize the log4net system properly.

I assume it's not finding the configuration information properly. What am I
doing wrong?

Any pointers or help you can provide would be great.

Thanks,

Mike van de Vijsel
[EMAIL PROTECTED]

Reply via email to