-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
40 lines (35 loc) · 1.04 KB
/
App.xaml.cs
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
using Serilog;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using Serilog;
namespace WpfApp1
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// Configure Serilog to log to a file and console (optional)
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console() // Optional for console logging
.WriteTo.File("logs/logfile.log", rollingInterval: RollingInterval.Day)
.CreateLogger();
Log.Information("Application started!");
}
protected override void OnExit(ExitEventArgs e)
{
// Ensure to flush and close loggers on exit
Log.CloseAndFlush();
base.OnExit(e);
}
}
}