protected virtual void ConfigureLogging(HostBuilderContext ctx, ILoggingBuilder logging)
        {
            var cfg     = ctx.Configuration;
            var section = cfg.GetSection(AppHostBuilder.LoggingSectionName);

            if (AppHostBuilder.IsTestHost)
            {
                logging.AddDebug();
                return;
            }
            logging.AddConfiguration(section);
            logging.AddConsole();
            logging.AddDebug();
            logging.AddEventSourceLogger();
        }
示例#2
0
 /// <summary>
 /// Configures an <see cref="ILoggingBuilder"/> with the base logging providers.
 /// </summary>
 /// <param name="loggingBuilder">The logging builder to configure.</param>
 private static void ConfigureBaseLogging(ILoggingBuilder loggingBuilder)
 {
     loggingBuilder.ClearProviders();
     loggingBuilder.AddConsole();
     loggingBuilder.AddDebug();
     loggingBuilder.AddEventSourceLogger();
 }
 public static void ConfigureLogging(WebHostBuilderContext host, ILoggingBuilder builder)
 {
     builder.AddConfiguration(host.Configuration.GetSection("Logging"));
     builder.AddConsole();
     builder.AddDebug();
     builder.AddFilter(DbLoggerCategory.Database.Connection.Name, LogLevel.Information);
 }
示例#4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggingBuilder loggerFactory)
        {
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            if (env.EnvironmentName.Equals("Development"))
            {
                //var delay = new TimeSpan(0, 0, 0, 0, 300); //300 ms
                var delay = new TimeSpan(0, 0, 1); // 1s
                app.UseSimulatedLatency(delay, delay);

                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
        }
 private static void ConfigureLogging(HostBuilderContext hostingContext, ILoggingBuilder logging)
 {
     // logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
     logging.AddConsole();
     logging.AddDebug();
     logging.AddEventSourceLogger();
 }
示例#6
0
 protected virtual void ConfigureLogging(WebHostBuilderContext context, ILoggingBuilder logging)
 {
     logging.ClearProviders();
     logging.AddConfiguration(GetLoggingConfiguration(context.Configuration));
     logging.AddConsoleLogger();
     logging.AddDebug();
 }
示例#7
0
        protected override void ConfigureLogging(ILoggingBuilder builder)
        {
            base.ConfigureLogging(builder);

            // Add additional loggers or configuration
            builder.AddDebug().AddFilter(logLevel => true);
        }
示例#8
0
 static void ConfigureLogger(WebHostBuilderContext ctx, ILoggingBuilder logging)
 {
     // Setups up the logging configuration from the location of our json config information
     logging.AddConfiguration(ctx.Configuration.GetSection("Logging"));
     logging.AddConsole();
     logging.AddDebug();
 }
示例#9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app,
                              IHostEnvironment env,
                              ILoggingBuilder loggerFactory,
                              ISeriLogger seriLogger,
                              IHostApplicationLifetime appLifetime,
                              EnvironmentConfig environmentConfig)
        {
            seriLogger.Configure(loggerFactory, Configuration, appLifetime, env, environmentConfig);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                loggerFactory.AddConfiguration(Configuration.GetSection("Logging"));
                loggerFactory.AddConsole();
                loggerFactory.AddDebug();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            app.UseRouting();
            app.UseEndpoints(endpoints => {
                endpoints.MapControllers();
            });
        }
示例#10
0
 public void ConfigureLogging(ILoggingBuilder loggingBuilder)
 {
     loggingBuilder.AddDebug()
     .AddFilter("Microsoft", LogLevel.Debug)
     .AddFilter("System", LogLevel.Warning)
     .AddFilter("BlazorApp", LogLevel.Debug);
 }
示例#11
0
        public static ILoggingBuilder AddLogging(this ILoggingBuilder builder, PiraeusConfig config)
        {
            LoggerType loggerTypes = config.GetLoggerTypes();

            //if (loggerTypes.HasFlag(LoggerType.None))
            //{
            //    return builder;
            //}

            LogLevel logLevel = Enum.Parse <LogLevel>(config.LogLevel, true);


            if (loggerTypes.HasFlag(LoggerType.Console))
            {
                builder.AddConsole();
            }

            if (loggerTypes.HasFlag(LoggerType.Debug))
            {
                builder.AddDebug();
            }



            builder.SetMinimumLevel(logLevel);

            return(builder);
        }
示例#12
0
        private void ConfigureLogging(HostBuilderContext context, ILoggingBuilder loggingBuilder)
        {
            var configuration  = context.Configuration;
            var loggingSection = configuration.GetSection("Logging");

            try
            {
                loggingBuilder.ClearProviders();
                loggingBuilder.AddConsole();
                loggingBuilder.AddDebug();

                var logFile = loggingSection.GetSection("File:Path").Value;
                if (!string.IsNullOrWhiteSpace(logFile))
                {
                    var logFileExpanded = Environment.ExpandEnvironmentVariables(logFile);
                    var directoryName   = Path.GetDirectoryName(logFileExpanded);
                    Directory.CreateDirectory(directoryName);

                    loggingBuilder.AddFile(loggingSection);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"Warning. Could not create logfile: Exception: {e}");
            }
        }
示例#13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggingBuilder loggerFactory)
        {
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            // Enable Api Extensions
            app.UseApiExtensions();


            app.UseMvc();

            // Enable middleware to serve generated Swagger as a JSON endpoint
            app.UseSwagger(c =>
            {
                c.RouteTemplate = "docs/{documentName}/swagger.json";
            });

            // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/docs/v1/swagger.json", "V1 Documentation");
                options.SwaggerEndpoint("/docs/v2/swagger.json", "V2 Documentation");
            });

            app.UseSwaggerUiRedirect();
        }
示例#14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggingBuilder loggerFactory)
        {
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            //Add authorization middleware
            app.UseAuth();

            app.UseSession();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseSwagger();
            app.UseSwaggerUi();
        }
示例#15
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app, ILoggingBuilder loggingBuilder)
        {
            loggingBuilder.AddConsole();
            loggingBuilder.AddDebug();

            app.UseMvc();
        }
 /// <summary>
 /// 配置日志
 /// </summary>
 /// <param name="hostingContext"></param>
 /// <param name="builder"></param>
 private static void ConfigLogging(HostBuilderContext hostingContext, ILoggingBuilder builder)
 {
     builder.ClearProviders();
     builder.SetMinimumLevel(LogLevel.Trace);
     builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
     builder.AddConsole();
     builder.AddDebug();
 }
示例#17
0
        private static void SetupLogging(HostBuilderContext context,
                                         ILoggingBuilder builder)
        {
            builder.ClearProviders();

            builder.AddDebug().SetMinimumLevel(LogLevel.Debug);
            builder.AddConsole().SetMinimumLevel(LogLevel.Debug);
        }
示例#18
0
 public static void ConfigureLogging(WebHostBuilderContext hostingContext, ILoggingBuilder logging)
 {
     logging.ClearProviders();
     logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
     logging.AddConsole();
     logging.AddDebug();
     logging.AddEventSourceLogger();
 }
示例#19
0
        /// <summary>
        ///     Configures logging.
        /// </summary>
        /// <remarks>
        ///     Called by <see cref="ConfigureServices" /> after building the <see cref="IServiceProvider" />.
        /// </remarks>
        /// <param name="loggingBuilder">The <see cref="ILoggingBuilder"/> to configure.</param>
        protected virtual void ConfigureLogging(ILoggingBuilder loggingBuilder)
        {
            var configuration = Configuration.GetSection("Logging");

            loggingBuilder.AddConfiguration(configuration);
            loggingBuilder.AddConsole();
            loggingBuilder.AddDebug();
        }
示例#20
0
        public static ILoggingBuilder AddInfrastructureLogging(this ILoggingBuilder logging, WebHostBuilderContext hostingContext)
        {
            logging.AddApplicationInsights();
            logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
            logging.AddConsole();
            logging.AddDebug();

            return(logging);
        }
 public static ILoggingBuilder AddCustom(this ILoggingBuilder builder, string value)
 {
     return(value switch
     {
         NewtomsoftConfiguration.CONSOLE_OUTPUT => builder.AddConsole(),
         NewtomsoftConfiguration.DEBUG_OUTPUT => builder.AddDebug(),
         NewtomsoftConfiguration.JSONCONSOLE_OUTPUT => builder.AddJsonConsole(),
         _ => builder,
     });
示例#22
0
        /// <summary>
        /// 添加ILoggerProvider
        /// </summary>
        /// <param name="context"></param>
        /// <param name="loggingBuilder"></param>
        private static void ConfigureLogging(HostBuilderContext context, ILoggingBuilder loggingBuilder)
        {
            loggingBuilder.AddConfiguration(context.Configuration.GetSection("Logging"));
#if DEBUG
            loggingBuilder.AddDebug();
            loggingBuilder.AddConsole();
#endif
            loggingBuilder.AddNLogLogging();
        }
示例#23
0
 public static void ConfigureLogging(HostBuilderContext hostingContext, ILoggingBuilder logging)
 {
     logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
     logging.AddConsole();
     if (hostingContext.HostingEnvironment.IsDevelopment())
     {
         logging.AddDebug();
     }
 }
示例#24
0
 private static void SetupLogRole(ILoggingBuilder loggingBuilder)
 {
     loggingBuilder.AddConsole();
     loggingBuilder.AddDebug();
     loggingBuilder.AddEventLog(new Microsoft.Extensions.Logging.EventLog.EventLogSettings()
     {
         MachineName = ""
     });
 }
 public static void ConfigureAppSharedLogging(WebHostBuilderContext hostingContext, ILoggingBuilder logging)
 {
     logging.AddConsole();
     logging.AddDebug();
     logging.AddFilter(DbLoggerCategory.Database.Connection.Name, LogLevel.Information);
     logging.AddFilter("AgencyPro", LogLevel.Debug);
     logging.AddFilter("Microsoft.AspNetCore", LogLevel.Warning);
     logging.AddFilter("IdentityServer4", LogLevel.Warning);
 }
示例#26
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggingBuilder loggingBuilder)
        {
            loggingBuilder.AddConsole();
            loggingBuilder.AddDebug();

            app.UseEndpoints(endpoints => {
                endpoints.MapDefaultControllerRoute();
            });
        }
示例#27
0
        /// <summary>
        /// Adds the logging.
        /// </summary>
        /// <param name="logging">The logging.</param>
        /// <param name="configuration">The configuration.</param>
        /// <returns></returns>
        public static ILoggingBuilder AddLogging(this ILoggingBuilder logging, IConfiguration configuration)
        {
            logging.AddConfiguration(configuration);
            logging.AddConsole();
            logging.AddDebug();
            logging.AddEventSourceLogger();
            logging.AddFileLogging(configuration);

            return(logging);
        }
示例#28
0
        private static void ConfigureLogging(HostBuilderContext hostBuilderContext, ILoggingBuilder loggingBuilder)
        {
            LoggerConfiguration loggerConfiguration = new LoggerConfiguration()
                                                      .ReadFrom.Configuration(hostBuilderContext.Configuration);

            Log.Logger = loggerConfiguration.CreateLogger();

            loggingBuilder.AddConsole();
            loggingBuilder.AddDebug();
        }
示例#29
0
        private static void ConfigureLogging(WebHostBuilderContext hostingContext, ILoggingBuilder loggingBuilder)
        {
            loggingBuilder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
            loggingBuilder.AddConsole();
            loggingBuilder.AddDebug();

            LayoutRenderer.Register("basedir", (logEvent) => hostingContext.HostingEnvironment.ContentRootPath);
            LayoutRenderer.Register <AspNetBuildDateLayoutRenderer>("custom-build-date");

            LogHolder.Init(new NLogFactory());
        }
示例#30
0
        private static void SetupAppLogging(WebHostBuilderContext context, ILoggingBuilder loggingBuilder)
        {
            loggingBuilder.AddConfiguration(context.Configuration.GetSection("Logging"));
            loggingBuilder.AddConsole();
            loggingBuilder.AddDebug();

            loggingBuilder.AddFilter <ConsoleLoggerProvider>((category, logLevel) =>
            {
                return(category == typeof(Startup).FullName);
            });
        }