Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.ServiceProcess;
- namespace Iminetcore
- {
- class LoggingService : ServiceBase
- {
- private const string _logFileLocation = @"C:\temp\servicelog.txt";
- private void Log(string logMessage)
- {
- //Directory.CreateDirectory(Path.GetDirectoryName(_logFileLocation));
- //File.AppendAllText(_logFileLocation, DateTime.UtcNow.ToString() + " : " + logMessage + Environment.NewLine);
- }
- protected override void OnStart(string[] args)
- {
- Log("Starting");
- base.OnStart(args);
- }
- protected override void OnStop()
- {
- Log("Stopping");
- base.OnStop();
- }
- protected override void OnPause()
- {
- Log("Pausing");
- base.OnPause();
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- ServiceBase.Run(new LoggingService());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement