Hi,
why ist the date not written?
Why green wavy line?
I need a logger for whole application, global Logger. Did I make it correct?
How I can start the console logger?
How I can start the console logger only in DEBUG mode?
Greetings Markus
public partial class MainWindow : Window
{
// https://github.com/serilog/serilog-sinks-rollingfile
// serilog analyser
// install-Package Serilog
// Install-Package Serilog.Sinks.RollingFile
//Install-Package Serilog.Sinks.ColoredConsole
// Install-Package Serilog.Extensions.Logging
// Install-Package Serilog.Sinks.File
// Install-Package Serilog.Sinks.Console
// https://marketplace.visualstudio.com/items?itemName=Suchiman.SerilogAnalyzer
//private static readonly ILogger Log;
// private static int I;
public MainWindow()
{
InitializeComponent();
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console()
// .WriteTo.RollingFile(@"c:\temp\Log-{Date}.txt")
.WriteTo.File(@"logs\Log-{Date}.txt", rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true, fileSizeLimitBytes: 100000)
// .WriteTo.File("logs\\myapp.txt", rollingInterval: RollingInterval.Day)
.CreateLogger();
Log.Information("Hello, world!");
//Log.Write("TEST write");
//var logger = new LoggerConfiguration()
// .WriteTo.ColoredConsole()
// .WriteTo.RollingFile(@"c:\temp\Log-{Date}.txt")
// .CreateLogger();
//Log = logger;
int I = 0;
I++;
Log.Information($"Logger created {I}");
var appointment =
new { Id = 1, Subject = "Meeting of database migration", Timestamp = new DateTime(2020, 7, 11) };
Log.Information($"An appointment is booked successfully: {appointment.Id}");
Log.Error($"Failed #TEST# to book an appointment: {appointment.Timestamp}");
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
int i = 3;
Log.Information($"Logger created Button Click {i}");
}