logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anders Löfgren <and...@storaryr.com>
Subject Newbie problem
Date Mon, 08 Oct 2007 23:09:41 GMT
 

I’m trying to configure log4net for a console application .net 2.0. I can’t
even get the simplest configuration to work. I put this configuration in my
app.config:

 

<configuration>

  <configSections>

    <section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />

  </configSections>

  

  <appSettings>

    <add key="log4net.Internal.Debug" value="true"/>

  </appSettings>

 

  <log4net>

 

    <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="INFO"/>

      <appender-ref ref="ConsoleAppender"/>

    </root>

 

  </log4net>

 

</configuration>

 

And in my code I fetch the logger through

 

private static readonly ILog log = LogManager.GetLogger(typeof(MyClass));

 

and the tries to log by:

 

                if (log.IsInfoEnabled)

                {

                    log.Info("Log something");

                }

 

Nothing is logged and when I debug the code I can see that the log instance
is not enabled on any level. 

As can be seen from above I have enabled internal logging which give me some
output:

 

log4net: log4net assembly [log4net, Version=1.2.10.0, Culture=neutral,
PublicKey

Token=null]. Loaded from [C:\Documents and Settings\anlo\My Documents\Visual
Stu

dio 2005\Projects\KasConsumerWeb\TransferKasData\bin\Debug\log4net.dll].
(.NET R

untime [2.0.50727.832] on Microsoft Windows NT 5.1.2600 Service Pack 2)

log4net: DefaultRepositorySelector: defaultRepositoryType
[log4net.Repository.Hi

erarchy.Hierarchy]

log4net: DefaultRepositorySelector: Creating repository for assembly
[KasDataSup

port, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]

log4net: DefaultRepositorySelector: Assembly [KasDataSupport,
Version=1.0.0.0, C

ulture=neutral, PublicKeyToken=null] Loaded From [C:\Documents and
Settings\anlo

\My Documents\Visual Studio
2005\Projects\KasConsumerWeb\TransferKasData\bin\Deb

ug\KasDataSupport.dll]

log4net: DefaultRepositorySelector: Assembly [KasDataSupport,
Version=1.0.0.0, C

ulture=neutral, PublicKeyToken=null] does not have a RepositoryAttribute
specifi

ed.

log4net: DefaultRepositorySelector: Assembly [KasDataSupport,
Version=1.0.0.0, C

ulture=neutral, PublicKeyToken=null] using repository
[log4net-default-repositor

y] and repository type [log4net.Repository.Hierarchy.Hierarchy]

log4net: DefaultRepositorySelector: Creating repository
[log4net-default-reposit

ory] using type [log4net.Repository.Hierarchy.Hierarchy]

Press the Enter key to exit the program.

 

As I understand it from the output and from debugging the appender is not
created in the Repository. Am I right? And in that case why?

 

What am I doing wrong?

 

Regards 

 

A


Mime
View raw message