-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogHelper.cs
More file actions
41 lines (36 loc) · 1.12 KB
/
Copy pathLogHelper.cs
File metadata and controls
41 lines (36 loc) · 1.12 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
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BaseCommon
{
public class LogHelper
{
public static log4net.ILog Log;
static LogHelper()
{
Log = log4net.LogManager.GetLogger("default");
NameValueCollection appSettings = ConfigurationManager.AppSettings;
string logFileName = appSettings["TraceLogFile"];
if (!string.IsNullOrEmpty(logFileName))
{
foreach (TraceListener tl in Trace.Listeners)
{
var _MyTrace = tl as DefaultTraceListener;
if (_MyTrace != null)
{
_MyTrace.LogFileName = logFileName;
MyTrace = _MyTrace;
break;
}
}
}
if (MyTrace == null) MyTrace = Trace.Listeners[0];
}
public static TraceListener MyTrace;
}
}