-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLogManager.cs
More file actions
44 lines (39 loc) · 1.43 KB
/
LogManager.cs
File metadata and controls
44 lines (39 loc) · 1.43 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
using System;
namespace CodeFactory.Logging
{
/// <summary>
/// Manager class that returns the correct instance of the logger managed by code factory.
/// </summary>
public static class LogManager
{
/// <summary>
/// Loads the target logger instance.
/// </summary>
/// <typeparam name="T">The target class type to be logged.</typeparam>
/// <returns>Instance of the target code factory logger.</returns>
public static ILogger GetLogger<T>() where T : class
{
Type loggerType = typeof(T);
return GetLogger(loggerType.FullName);
}
/// <summary>
/// Loads the target logger instance.
/// </summary>
/// <param name="targetType">The target type to load the logger for.</param>
/// <returns>Instance of the target code factory logger.</returns>
public static ILogger GetLogger(Type targetType)
{
return GetLogger(targetType.FullName);
}
/// <summary>
/// Loads the target logger instance.
/// </summary>
/// <param name="loggerName">The name of the logger to be loaded.</param>
/// <returns>Instance of the target code factory logger.</returns>
public static ILogger GetLogger(string loggerName)
{
var logger = NLog.LogManager.GetLogger(loggerName);
return new NLogLogger(logger);
}
}
}