public override void Initialize() { const string template = "[{Timestamp:yyyy-MM-dd HH:mm:ss}] [{Level:u3}] {Message:lj}{NewLine}{Exception}"; const string latestLogPath = @"logs\latest.log"; if (File.Exists(latestLogPath)) { File.Delete(latestLogPath); } var logger = new LoggerConfiguration() .MinimumLevel.Information() .WriteTo.File(latestLogPath, outputTemplate: template) .WriteTo.File(@"logs\log-.log", outputTemplate: template, rollingInterval: RollingInterval.Day, retainedFileCountLimit: 9) .CreateLogger(); SerilogLogger.Initialize(logger); Log.Logger = logger; AppDomain.CurrentDomain.UnhandledException += (sender, args) => { if (args.ExceptionObject is Exception ex) { Log.Error(ex, $"Caught an unhandled {ex.GetType().Name} exception, {(args.IsTerminating ? "" : "not ")}terminating the program"); } else { Log.Error($"Caught an unidentified unhandled exception, {(args.IsTerminating ? "" : "not ")}terminating the program"); } }; Log.Information("Opening a new instance of AudioSensei"); AvaloniaXamlLoader.Load(this); }
private static void InitializeLogging() { SerilogLogger.Initialize(new LoggerConfiguration() .MinimumLevel.Warning() .WriteTo.Trace(outputTemplate: "{Area}: {Message}") .CreateLogger()); }
private void InitializeLogging() { SerilogLogger.Initialize(new LoggerConfiguration() .MinimumLevel.Information() .WriteTo.Debug() .CreateLogger()); }
private void InitializeLogging() { SerilogLogger.Initialize(new LoggerConfiguration() .MinimumLevel.Verbose() .Filter.ByIncludingOnly(Matching.WithProperty("Area", LogArea.Binding)) .WriteTo.Debug(outputTemplate: "{Area}: {Message}") .CreateLogger()); }
private static void Main(string[] args) { Serilog.Log.Logger = new LoggerConfiguration() .MinimumLevel.Information() .WriteTo.Console(outputTemplate: "{Area}: {Message} {Exception}{NewLine}") .CreateLogger(); SerilogLogger.Initialize(Serilog.Log.Logger); AppBuilder.Configure <App>().UsePlatformDetect().LogToDebug().Start(AppMain, args); }
private static void LoggerInit() { SerilogLogger.Initialize(new LoggerConfiguration() .MinimumLevel.Warning() .WriteTo.File("Logs/GUILog.log") .CreateLogger()); Log.Logger = new LoggerConfiguration() .MinimumLevel.Error() .WriteTo.File("Logs/Errors.log") .CreateLogger(); }
public override void Initialize() { AvaloniaXamlLoaderPortableXaml.Load(this); #if DEBUG SerilogLogger.Initialize(new LoggerConfiguration() .MinimumLevel.Warning() .WriteTo.Trace(outputTemplate: "{Area}: {Message}") .CreateLogger()); #endif }
private static void InitializeLogging() { var logger = new LoggerConfiguration() .MinimumLevel.Warning() /*.MinimumLevel.Override("NHibernate", LogEventLevel.Debug)*/ .MinimumLevel.Override("NHibernate.SQL", LogEventLevel.Debug) .WriteTo.Async(a => a.File($"logs/{DateTime.Now.ToString("s").Replace(":", ".")}.log")) .CreateLogger(); Log.Logger = logger; SerilogLogger.Initialize(logger); Locator.CurrentMutable.UseSerilogFullLogger(logger); }
private static void SetupLogging() { Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .MinimumLevel.Debug() .WriteTo.Console() #if DEBUG .WriteTo.Debug() #endif .CreateLogger(); SerilogLogger.Initialize(Log.Logger); Locator.CurrentMutable.UseSerilogFullLogger(); }
public override void Initialize() { var logger = new LoggerConfiguration() .MinimumLevel.Information() .WriteTo.Debug() .WriteTo.File("Daktyl.log") .CreateLogger(); SerilogLogger.Initialize(logger); Log.Logger = logger; Console.SetOut(new LogWriter(LogEventLevel.Information)); Console.SetError(new LogWriter(LogEventLevel.Error)); AvaloniaXamlLoader.Load(this); }
// Initialization code. Don't use any Avalonia, third-party APIs or any // SynchronizationContext-reliant code before AppMain is called: things aren't initialized // yet and stuff might break. public static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console() .CreateLogger(); #if DEBUG SerilogLogger.Initialize(new LoggerConfiguration() .MinimumLevel.Is(LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.Console(outputTemplate: "[{Area}] {Message} ({SourceType} #{SourceHash})\n") .CreateLogger()); #endif BuildAvaloniaApp().Start(AppMain, args); }
public override void OnFrameworkInitializationCompleted() { #if DEBUG SerilogLogger.Initialize(new LoggerConfiguration() .MinimumLevel.Warning() .WriteTo.Trace(outputTemplate: "{Area}: {Message}") .CreateLogger()); #endif var view = new FeedbackView(); var context = new FeedbackViewModel( new AvaloniaSender(view), new Clock()); view.DataContext = context; view.Show(); base.OnFrameworkInitializationCompleted(); }
public static void Main(string[] args) { Log.Logger = SerilogLogger.Initialize(); try { Log.Information("Starting up"); CreateHostBuilder(args).Build().Run(); } catch (Exception ex) { Log.Fatal(ex, "Application start-up failed"); } finally { Log.CloseAndFlush(); } }