-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogger.cs
47 lines (38 loc) · 1.43 KB
/
Logger.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace RestProxy.Net
{
public class Logger
{
private bool debug;
public string DebugMode
{
get { return debug.ToString().ToLower(); }
set
{
string valLowStr = value.ToLower();
if ((valLowStr.ToLower() == "false") || (valLowStr.ToLower() == "off") || (valLowStr.ToLower() == "0"))
debug = false;
if ((valLowStr.ToLower() == "true") || (valLowStr.ToLower() == "on") || (valLowStr.ToLower() == "1"))
debug = true;
}
}
//string logFile = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\RestProxyNet_log.txt";
private string logFile = "";
public Logger()
{
//logFile = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\RestProxyNet_log.txt"; // "MyDocuments" does not resolve on IIS
logFile = "C:\\RestProxy\\RestProxyNet_log.txt";
DebugMode = "true";
System.IO.File.Create(logFile).Close(); // Create empty log file if not exists
}
public void Log(string message)
{
if (!debug)
return;
System.IO.File.AppendAllText(logFile, DateTime.Now + "\t" + message + Environment.NewLine);
}
}
}