using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using log4net.Appender;
using log4net.Core;
namespace LiveLogger4Log4Net
{
public class WCFAppender : AppenderSkeleton
{
#region Public Instance Constructors
private ServiceHost host;
///
/// Initializes a new instance of the class.
///
///
/// The default constructor start the ServiceHost to listen for registration.
///
public WCFAppender()
{
try
{
host = new ServiceHost(typeof(AppenderService));
host.Open();
}
catch (Exception ex)
{
throw;
}
}
#endregion Public Instance Constructors
#region Override implementation of AppenderSkeleton
///
/// This method is called by the method.
/// It calls static method that is used to notify the log
/// to all registered clients.
///
/// The event to log.
///
///
/// Send the event to all registered listener.
///
///
/// Exceptions are passed to the .
///
///
protected override void Append(LoggingEvent loggingEvent)
{
AppenderService.Append(loggingEvent);
}
///
/// This appender requires a to be set.
///
/// true
///
///
/// This appender requires a to be set.
///
///
override protected bool RequiresLayout
{
get { return true; }
}
///
/// Close the appender, close the host and call base version.
///
protected override void OnClose()
{
host.Close();
base.OnClose();
}
#endregion Override implementation of AppenderSkeleton
}
}