forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventLogFactory.cs
More file actions
50 lines (45 loc) · 1.69 KB
/
EventLogFactory.cs
File metadata and controls
50 lines (45 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
namespace ServiceStack.Logging.EventLog
{
/// <summary>
/// ILogFactory used to create an EventLogger
/// </summary>
public class EventLogFactory : ILogFactory
{
private readonly string eventLogName;
private readonly string eventLogSource;
/// <summary>
/// Initializes a new instance of the <see cref="EventLogFactory"/> class.
/// </summary>
/// <param name="eventLogName">Name of the event log.</param>
public EventLogFactory(string eventLogName) : this(eventLogName, null) { }
/// <summary>
/// Initializes a new instance of the <see cref="EventLogFactory"/> class.
/// </summary>
/// <param name="eventLogName">Name of the event log. Default is 'ServiceStack.Logging.EventLog'</param>
/// <param name="eventLogSource">The event log source. Default is 'Application'</param>
public EventLogFactory(string eventLogName, string eventLogSource)
{
this.eventLogName = eventLogName ?? "ServiceStack.Logging.EventLog";
this.eventLogSource = eventLogSource ?? "Application";
}
/// <summary>
/// Gets the logger.
/// </summary>
/// <param name="type">The type.</param>
/// <returns></returns>
public ILog GetLogger(Type type)
{
return GetLogger(type.ToString());
}
/// <summary>
/// Gets the logger.
/// </summary>
/// <param name="typeName">Name of the type.</param>
/// <returns></returns>
public ILog GetLogger(string typeName)
{
return new EventLogger(eventLogName, eventLogSource);
}
}
}