Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public static int Main(string[] args)
        {
            ConfigureLoggly();

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .MinimumLevel.Override("Microsoft", LogEventLevel.Debug)
                         .Enrich.FromLogContext()
                         .Enrich.WithProcessId()
                         .Enrich.WithThreadId()
                         .Enrich.With(new EnvironmentUserNameEnricher())
                         .Enrich.With(new MachineNameEnricher())
                         .WriteTo.Async(s => s.RollingFileAlternate(
                                            LogConfiguration.GetLoggingPath(Configuration),
                                            outputTemplate: "[{ProcessId}] {Timestamp} [{ThreadId}] [{Level}] [{SourceContext}] [{Category}] {Message}{NewLine}{Exception}",
                                            fileSizeLimitBytes: 10 * 1024 * 1024,
                                            retainedFileCountLimit: 100,
                                            formatProvider: CreateLoggingCulture())
                                        .MinimumLevel.Debug())
                         .WriteTo.Loggly()
                         .CreateLogger();

            Serilog.Debugging.SelfLog.Enable(msg =>
            {
                Debug.Print(msg);
                Debugger.Break();
            });

            try
            {
                Log.Information("Init:ImageGallery.Client");
                BuildWebHost(args).Run();
                return(0);
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, "Host terminated unexpectedly");
                return(1);
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }