-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogManager.cs
More file actions
43 lines (40 loc) · 1.34 KB
/
Copy pathLogManager.cs
File metadata and controls
43 lines (40 loc) · 1.34 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Threading;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
namespace KXTX.IT.BICenter
{
class LogManager
{
public static string logFileFolder = (ConfigurationManager.AppSettings["JobControlLogPath"].ToString() + "JobControl_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString());
public static string strFilePath = logFileFolder + "_" + DateTime.Now.ToFileTime().ToString() + ".txt";
public static StringBuilder JobControlLog = new StringBuilder();
public static void AppendLog(string logMsg)
{
JobControlLog.AppendLine(logMsg);
}
public static void LogFile()
{
FileStream fs = new FileStream(strFilePath, FileMode.CreateNew, FileAccess.Write);
try
{
StreamWriter sw = new StreamWriter(fs);
sw.Write(JobControlLog);
sw.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw new Exception("Log file failed", e);
}
}
}
}