Skip to search.

(*) Scheduled Maintenance: We are undertaking some essential, but extensive maintenance to improve Yahoo! Calendar. Your Group Calendar is being migrated to a much improved version of Yahoo! Calendar. During the maintenance period, you may not have access to your Groups Calendar. We sincerely apologize for this inconvenience. Your Groups Calendar is in great shape and we are working to have it available again as quickly as possible - Yahoo! Groups & Yahoo! Calendar Team

nservicebus

Group Information

  • Members: 1282
  • Category: Software
  • Founded: Dec 16, 2007
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.
Click here for the latest updates on Groups Message search

Messages

  Messages Help
Advanced
Log4Net and ColoredConsoleAppender   Message List  
Reply Message #9155 of 13974 |
I've been trying to get the ColoredConsoleAppender to work with NServiceBus and Log4Net. It's probably dead simple, but I simply cannot get it to work.

Here are some of the things I've tried, using my own host:
 var bus = NServiceBus.Configure.With()
                    .Log4Net(log4net.Config.XmlConfigurator.Configure)
                    .CastleWindsorBuilder(ConfigureWindsor())
                    .XmlSerializer()
                    .MsmqTransport()
                        .IsTransactional(true)
                        .PurgeOnStartup(false)
                    .UnicastBus()
                        .ImpersonateSender(false)
                        .LoadMessageHandlers()
                    .CreateBus()
                    .Start();
This doesn't compile because of the XmlConfigurator parse to Log4Net. Then I tried:
.Log4Net<ColoredConsoleAppender>(ca => { ca.Threshold = Level.Debug; ca.AddMapping(new ColoredConsoleAppender.LevelColors(){BackColor = ColoredConsoleAppender.Colors.Blue, ForeColor = ColoredConsoleAppender.Colors.Red, Level = Level.Debug});})
This works and it's colored for this precise level. However, I'd like to be able to have the logging controlled by a config file or profiles.

Then I tried appending this line after setting up my bus:
NServiceBus.SetLoggingLibrary.Log4Net(log4net.Config.XmlConfigurator.Configure);

This fails in the console with an error from Log4Net saying:
log4net:WARN XmlHierarchyConfigurator: Unable to set property [mapping] on objec
t [log4net.Appender.ColoredConsoleAppender] using value [
            
            
            ] (with acceptable conversion types)

My log4net app.config settings:
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>

  <log4net>
    <appender name="console" type="log4net.Appender.ColoredConsoleAppender">
      <target value="Console.Error" />
      <mapping>
            <level value="FATAL" />
            <foreColor value="Red" />
            <backColor value="White" />
      </mapping>
      <layout type="log4net.Layout.PatternLayout">
          <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n"/>
        </layout>
      <layout type="log4net.Layout.SimpleLayout" />
    </appender>
    <root>
      <level value="ALL"/>
      <appender-ref ref="console"/>
    </root>
  </log4net>

I've tried similar things for the Generic Host with same result. I've tried debugging and calling "LogManager.GetAllRepositories()[0].GetAppenders()" in the immediate window, making sure that my appender is in fact at ColoredConsoleAppender.

Any suggestions will be appreciated.

Thanks!

Kristian




Fri Nov 5, 2010 4:25 pm

kristensenkr...
Offline Offline
Send Email Send Email

Message #9155 of 13974 |
Expand Messages Author Sort by Date

I've been trying to get the ColoredConsoleAppender to work with NServiceBus and Log4Net. It's probably dead simple, but I simply cannot get it to work. Here...
Kristian Kristensen
kristensenkr... Offline Send Email
Nov 5, 2010
4:25 pm

I found a solution to my question. I've detailed it in my blog post which you can find here: http://bit.ly/aZCMXj Kristian ... -- WhizIT - http://www.whizit.dk...
Kristian Kristensen
kristensenkr... Offline Send Email
Nov 15, 2010
7:56 pm

Kristian, To get NServiceBus to accept the logging configuration from the app.config, just call: ...
Udi Dahan
udidahan7 Offline Send Email
Nov 16, 2010
1:01 pm
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help