logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sidharth Nayyar <Sidharth.Nay...@pulsion.co.uk>
Subject RE: No appenders found
Date Wed, 19 Aug 2009 13:59:03 GMT
Thanks Ross, that's it logging now.

Unfortunately it's only using the appenders as specified in the root element, even though
I'm trying to access it by "MyLogger" name. So I presume MyLogger isn't registered with the
default repository? Should I therefore create a new repository with MyLogger name in order
to use that Logger?

Also is there some documentation that shows all the configuration elements? I looked at the
SDK but I couldn't find it.

Thanks again for all your help.

Regards,
Sidharth



From: Ross Hinkley [mailto:rosshinkley@gmail.com]
Sent: 19 August 2009 13:06
To: Log4NET User
Subject: Re: No appenders found

Sidharth,

I think it depends on the log4net section handler you're using.  That overload of configure
has specifies that the configuration must use the Log4NetConfigurationSectionHandler.  See:

 http://logging.apache.org/log4net/release/sdk/log4net.Config.XmlConfigurator.Configure_overload_2.html

for more information.

Alternatively, you could try the following in your code:

log4net.Config.XmlConfigurator.Configure(new FileInfo(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile));

-Ross
On Wed, Aug 19, 2009 at 5:11 AM, Sidharth Nayyar <Sidharth.Nayyar@pulsion.co.uk<mailto:Sidharth.Nayyar@pulsion.co.uk>>
wrote:

Hi Wolfgang,



Thanks for your quick response.



I've added this to the code now:

            if (!_defaultLog.Logger.Repository.Configured)

            {

                log4net.Config.XmlConfigurator.Configure(_defaultLog.Logger.Repository);

            }



But the repository is still appearing as unconfigured and still no appenders. I've even tried
doing a default XmlConfigurator.Configure(); before GetLogger() call. Is that the right way
of calling the Configure() method?



Sidharth



From: Wolfgang Trog [mailto:wolfgang@wollinet.com<mailto:wolfgang@wollinet.com>]
Sent: 19 August 2009 10:49
To: 'Log4NET User'
Subject: RE: No appenders found



Do you have a



XmlConfigurator.Configure();



Or one of the other possibilities to configure log4net somewhere in your code ?



--

Wolfgang



From: Sidharth Nayyar [mailto:Sidharth.Nayyar@pulsion.co.uk<mailto:Sidharth.Nayyar@pulsion.co.uk>]
Sent: Mittwoch, 19. August 2009 11:43
To: log4net-user@logging.apache.org<mailto:log4net-user@logging.apache.org>
Subject: No appenders found



Hello all,

I'm new to log4net, so sorry for the really basic question!



I've added this to the web.config of my site:



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

...

    <log4net>

        <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >

            <applicationName value="LoggingTest" />

            <layout type="log4net.Layout.PatternLayout">

                <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}]
- %message%newline" />

            </layout>

        </appender>

        <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">

            <file value="logfile" />

            <appendToFile value="true" />

            <rollingStyle value="Composite" />

            <datePattern value="yyyyMMdd" />

            <maxSizeRollBackups value="10" />

            <maximumFileSize value="1MB" />

            <layout type="log4net.Layout.PatternLayout">

                <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}]
- %message%newline" />

            </layout>

        </appender>

        <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender,log4net">

            <to value="test@test.com<mailto:test@test.com>" />

            <from value="from@from.com<mailto:from@from.com>" />

            <subject value=" Warning" />

            <smtpHost value="mail-relay.company.co.uk<http://mail-relay.company.co.uk>"
/>

            <bufferSize value="512" />

            <lossy value="false" />

            <evaluator type="log4net.Core.LevelEvaluator,log4net">

                <threshold value="WARN" />

            </evaluator>

            <layout type="log4net.Layout.PatternLayout,log4net">

                <conversionPattern value="%property{log4net:HostName} :: %level :: %message
%newlineLogger: %logger%newlineThread: %thread%newlineDate: %date%newlineNDC: %property{NDC}%newline%newline"
/>

            </layout>

        </appender>



        <!-- Set root logger level to DEBUG and its only appender to A1 -->

        <root>

            <level value="DEBUG" />

            <appender-ref ref="RollingFileAppender" />

        </root>



        <logger name="MyLogger">

            <level value="WARN" />

            <appender-ref ref="EventLogAppender" />

            <appender-ref ref="SmtpAppender" />

            <appender-ref ref="RollingFileAppender" />

        </logger>



    </log4net>



And in my code I have this:

        private static ILog _defaultLog;

...

            _defaultLog = log4net.LogManager.GetLogger("MyLogger");

            _defaultLog.Error("test");





However nothing gets written to event log, file or smtp. While debugging there doesn't seem
to be any appenders to the repository. So I'm presuming I haven't set up my configuration
properly. Unfortunately I can't see where I'm going wrong - can you see where I'm going wrong?



Thanks in advance.



Regards

Sidharth




Mime
View raw message