Commits

Ben Foster committed ddb9a61

Added Log4Net appender and re-added event handler

  • Participants
  • Parent commits 66d6ee7

Comments (0)

Files changed (4)

File NServiceBusAzure/ServiceConfiguration.Local.cscfg

     <ConfigurationSettings>
       <Setting name="AzureQueueConfig.ConnectionString" value="UseDevelopmentStorage=true" />
       <Setting name="AzureSubscriptionStorageConfig.ConnectionString" value="UseDevelopmentStorage=true" />
-      <Setting name="Diagnostics.Level" value="Error" />
+      <Setting name="Diagnostics.Level" value="Debug" />
       <Setting name="Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
       <Setting name="MessageForwardingInCaseOfFaultConfig.ErrorQueue" value="ErrorQueue" />
       <Setting name="MsmqTransportConfig.InputQueue" value="WebInputQueue" />

File Web/Global.asax.cs

 using System.Web.Routing;
 using NServiceBus;
 using NServiceBus.Config;
+using NServiceBus.Integration.Azure;
 
 namespace Web
 {
         {
             configure = Configure.WithWeb()
                 .DefaultBuilder()
+                .Log4Net(new AzureAppender())
                 .AzureConfigurationSource()
                 .AzureMessageQueue()
                     .JsonSerializer()

File Web/MessageSentEventHandler.cs

 using System.Diagnostics;
 using Events;
 using NServiceBus;
+using log4net;
 
 namespace Web
 {
     public class MessageSentEventHandler : IHandleMessages<MessageSentEvent>
     {
+        private readonly ILog log = LogManager.GetLogger(typeof(MessageSentEventHandler));
+
         public void Handle(MessageSentEvent message)
         {
-            Trace.WriteLine("A message was sent successfully.", "Information");
+            log.Debug("A message was sent successfully.");
         }
     }
 }

File Worker/SendMessageCommandHandler.cs

 using Commands;
 using Events;
 using NServiceBus;
-using System.Threading;
 
 namespace Worker
 {
         public void Handle(SendMessageCommand message) {
             Trace.WriteLine(string.Format("Received SendMessageCommand: {0}", message.Message));
 
-            // simulate processing
-            Thread.Sleep(5000);
-
             Bus.Publish(new MessageSentEvent { Message = message.Message });
         }
     }