Пример #1
0
        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);
        }
Пример #2
0
 private static void InitializeLogging()
 {
     SerilogLogger.Initialize(new LoggerConfiguration()
                              .MinimumLevel.Warning()
                              .WriteTo.Trace(outputTemplate: "{Area}: {Message}")
                              .CreateLogger());
 }
Пример #3
0
 private void InitializeLogging()
 {
     SerilogLogger.Initialize(new LoggerConfiguration()
                              .MinimumLevel.Information()
                              .WriteTo.Debug()
                              .CreateLogger());
 }
Пример #4
0
 private void InitializeLogging()
 {
     SerilogLogger.Initialize(new LoggerConfiguration()
                              .MinimumLevel.Verbose()
                              .Filter.ByIncludingOnly(Matching.WithProperty("Area", LogArea.Binding))
                              .WriteTo.Debug(outputTemplate: "{Area}: {Message}")
                              .CreateLogger());
 }
Пример #5
0
 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);
 }
Пример #6
0
 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();
 }
Пример #7
0
        public override void Initialize()
        {
            AvaloniaXamlLoaderPortableXaml.Load(this);

#if DEBUG
            SerilogLogger.Initialize(new LoggerConfiguration()
                                     .MinimumLevel.Warning()
                                     .WriteTo.Trace(outputTemplate: "{Area}: {Message}")
                                     .CreateLogger());
#endif
        }
Пример #8
0
        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);
        }
Пример #9
0
        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();
        }
Пример #10
0
        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);
        }
Пример #11
0
        // 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);
        }
Пример #12
0
        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();
        }
Пример #13
0
        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();
            }
        }