-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (47 loc) · 1.88 KB
/
Program.cs
File metadata and controls
52 lines (47 loc) · 1.88 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
44
45
46
47
48
49
50
51
52
// Copyright (c) One Identity LLC. All rights reserved.
namespace ServiceNowTicketValidator
{
using System;
using System.IO;
using System.Reflection;
using Serilog;
using Serilog.Events;
using Topshelf;
internal static class Program
{
private static void Main(string[] args)
{
if (Environment.UserInteractive)
{
Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Console()
.CreateLogger();
}
else
{
var loggingDirectory = ConfigUtils.ReadRequiredSettingFromAppConfig("LoggingDirectory", "logging directory");
if (!Path.IsPathRooted(loggingDirectory))
{
loggingDirectory = Path.Combine(Assembly.GetEntryAssembly().Location, loggingDirectory);
}
Log.Logger = new LoggerConfiguration().WriteTo.File(
Path.Combine(loggingDirectory, "ServiceNowTicketValidator-{Date}.log").ToString(),
LogEventLevel.Debug)
.CreateLogger();
}
HostFactory.Run(hostConfig =>
{
hostConfig.Service<ServiceNowTicketValidatorService>(service =>
{
service.ConstructUsing(c => new ServiceNowTicketValidatorService());
service.WhenStarted(s => s.Start());
service.WhenStopped(s => s.Stop());
});
hostConfig.UseSerilog();
hostConfig.StartAutomaticallyDelayed();
hostConfig.SetDisplayName("ServiceNowTicketValidator");
hostConfig.SetServiceName("SvcNowTktV");
hostConfig.SetDescription("Simple ServiceNow ticket validation and access request approval engine.");
});
}
}
}