using System;
namespace ServiceStack.Logging.EventLog
{
///
/// ILogFactory used to create an EventLogger
///
public class EventLogFactory : ILogFactory
{
private readonly string eventLogName;
private readonly string eventLogSource;
private readonly bool debugEnabled;
///
/// Initializes a new instance of the class.
///
/// Name of the event log. Default is 'ServiceStack.Logging.EventLog'
/// The event log source. Default is 'Application'
/// Whether to write EventLog entries for DEBUG logs
public EventLogFactory(string eventLogName = null, string eventLogSource = null, bool debugEnabled = false)
{
this.eventLogName = eventLogName ?? "ServiceStack.Logging.EventLog";
this.eventLogSource = eventLogSource ?? "Application";
this.debugEnabled = debugEnabled;
}
///
/// Gets the logger.
///
/// The type.
///
public ILog GetLogger(Type type)
{
return GetLogger(type.ToString());
}
///
/// Gets the logger.
///
/// Name of the type.
///
public ILog GetLogger(string typeName)
{
return new EventLogger(eventLogName, eventLogSource)
{
IsDebugEnabled = debugEnabled
};
}
}
}