Exemple #1
0
        protected override void StartApplication()
        {
            base.StartApplication();

            var logger = AtlasLogging.CreateLogger <SampleService>();

            logger.LogDebug("{info}", info.Info);
        }
Exemple #2
0
        public virtual void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IApplicationLifetime appLifetime)
        {
            AtlasLogging.LoggerFactory = loggerFactory;
            logger = AtlasLogging.CreateLogger <Startup>();

            app.UseMiddleware <CorrelationIdHandlerMiddleware>();
            app.UseMiddleware <UnhandledExceptionLogMiddleware>();
            app.UseMiddleware <ApiAccessLoggingMiddleware>();
            app.UseMiddleware <HttpNotFoundMiddleware>();

            if (ApplicationSettings.Hosting.SwaggerEnabled)
            {
                app.UseSwagger();
                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", GetType().Name);
                    c.RoutePrefix = string.Empty;
                });
            }

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

                if (ApplicationSettings.Hosting.AuthenticationRequired)
                {
                    object constraints = ApplicationSettings.Hosting.SwaggerEnabled
                        ? new { url = "^((?!swagger).)*$" }
                        : null;
                    routes.MapRoute(
                        name: "NotFound",
                        template: "{*url}",
                        defaults: new { controller = "Errors", action = "Handle404" },
                        constraints: constraints);
                }

                routes.Filter().OrderBy(QueryOptionSetting.Allowed).MaxTop(EnableQueryWithInlineCountAttribute.TopParamMaxValue).Count();
                routes.EnableDependencyInjection();
            });

            appLifetime.ApplicationStarted.Register(Start);
            appLifetime.ApplicationStopped.Register(Stop);
        }
Exemple #3
0
 protected Startable()
 {
     logger = AtlasLogging.CreateLogger(GetType().Name);
 }