forked from anaselhajjaji/log4net.Appender.Loki
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProgram.cs
More file actions
32 lines (28 loc) · 1010 Bytes
/
Copy pathProgram.cs
File metadata and controls
32 lines (28 loc) · 1010 Bytes
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
using System;
using System.IO;
using System.Threading;
namespace Example
{
class Program
{
private static readonly log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
static void Main(string[] args)
{
var fileInfo = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config");
if (fileInfo.Exists)
log4net.Config.XmlConfigurator.Configure(fileInfo);
else
throw new InvalidOperationException("No log config file found");
int count = 0;
while (true)
{
Thread.Sleep(2000);
logger.Debug($"Log number {count++}");
logger.Info($"Log number { count++ }");
logger.Warn($"Log number {count++}");
logger.Error($"Log number {count++}");
logger.Fatal($"Log number {count++}");
}
}
}
}