OneCompiler

Process&ErrorLogs - Vijay

156

-- ProcessLog.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestWindowsService
{
public class ProcessLog
{
public void ProcessLogFile(string strMessage)
{
string path = "D:\Logs\ProcessLog.txt";
using (StreamWriter writer = new StreamWriter(path, true))
{
writer.WriteLine(string.Format("Service Status Capture :- " + strMessage + " DateTime -- " + DateTime.Now.ToString("dd/mm/yyyy hh:mm:ss tt") + ""));
writer.Close();
}
}
}
}


ErrorLog.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestWindowsService
{
public class ErrorLog
{
public void ErrorlogFile(string strMessage)
{
string path = "D:\Logs\ErrorLog.txt";
using (StreamWriter writer = new StreamWriter(path, true))
{
writer.WriteLine(string.Format("Exception Capture :- " + strMessage + " DateTime -- " + DateTime.Now.ToString("dd/mm/yyyy hh:mm:ss tt") + ""));
writer.Close();
}
}
}
}