当前位置: 首页>>代码示例>>C#>>正文


C# IAppBuilder.CreateLogger方法代码示例

本文整理汇总了C#中IAppBuilder.CreateLogger方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.CreateLogger方法的具体用法?C# IAppBuilder.CreateLogger怎么用?C# IAppBuilder.CreateLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAppBuilder的用法示例。


在下文中一共展示了IAppBuilder.CreateLogger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ForceSslWhenAuthenticatedMiddleware

 public ForceSslWhenAuthenticatedMiddleware(OwinMiddleware next, IAppBuilder app, string cookieName, int sslPort)
     : base(next)
 {
     CookieName = cookieName;
     SslPort = sslPort;
     _logger = app.CreateLogger<ForceSslWhenAuthenticatedMiddleware>();
 }
开发者ID:henrycomein,项目名称:NuGetGallery,代码行数:7,代码来源:ForceSslWhenAuthenticatedMiddleware.cs

示例2: Configuration

        public void Configuration(IAppBuilder app)
        {
            ILogger webApiLogger = app.CreateLogger("System.Web.Http");
            OwinWebApiTracer tracer = new OwinWebApiTracer(webApiLogger);
            HttpConfiguration config = new HttpConfiguration();
            config.Routes.MapHttpRoute("DefaultHttpRoute", "api/{controller}");
            config.Services.Replace(typeof(ITraceWriter), tracer);

            app.Use<MyMiddleware>(app)
               .UseWebApi(config);
        }
开发者ID:RolandTG,项目名称:OwinSamples,代码行数:11,代码来源:Startup.cs

示例3: Configuration

        public void Configuration(IAppBuilder app)
        {
            //app.UseLog4Net();//from Web.config
            app.UseLog4Net("~/log4net.config");

            var logger = app.CreateLogger<Startup>();
            
            logger.WriteInformation("Application is started.");

            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();
            app.UseWebApi(config);            
        }
开发者ID:mirrobozik,项目名称:MB.Owin.Logging.Log4Net,代码行数:13,代码来源:Startup.cs

示例4: Configuration

        public void Configuration(IAppBuilder app)
        {
            initLog();
            app.UseNLog();

            var manager = new QManager(new QEventsListener(GlobalHost.ConnectionManager));

            GlobalHost.DependencyResolver.Register(
                typeof(QHub),
                () => new QHub(
                    manager,
                    app.CreateLogger<QHub>()));

            app.Use<SimpleHeaderAuthenticator>();
            app.MapSignalR();

            var logger = LogManager.GetCurrentClassLogger();
            logger.Info("Application started");
        }
开发者ID:lx223,项目名称:Q3,代码行数:19,代码来源:Startup.cs

示例5: Configuration

        // Invoked once at startup to configure your application.
        public void Configuration(IAppBuilder app)
        {
            this.logger = app.CreateLogger(this.GetType().Name);
            app.Run(async (context) => {
                logger.WriteInformation("Configuring...");

                var path = context.Request.Path;
                logger.WriteInformation("Has request for " + path + "!");
                if (!path.Value.Equals("/"))
                    return;
                logger.WriteInformation("Ok, processing request...");

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("https://hacker-news.firebaseio.com");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    HttpResponseMessage response = await client.GetAsync("/v0/topstories.json?print=pretty");
                    logger.WriteInformation("Got first response.");
                    if (response.IsSuccessStatusCode)
                    {
                        var arr = await response.Content.ReadAsAsync<dynamic>();
                        var responseId = (String)arr[0];
                        var itemUrl = String.Format("/v0/item/{0}.json?print=pretty", responseId);
                        response = await client.GetAsync(itemUrl);
                        logger.WriteInformation("Got second response.");
                        if (response.IsSuccessStatusCode)
                        {
                            var dict = await response.Content.ReadAsAsync<dynamic>();
                            var title = (String)dict["title"];
                            logger.WriteInformation(title);
                            await context.Response.WriteAsync(title);
                            return;
                        }
                    }
                    logger.WriteInformation("Error:" + await response.Content.ReadAsStringAsync());
                    await context.Response.WriteAsync("Service is not available!");
                }
            });
        }
开发者ID:ilyaigpetrov,项目名称:report-asp.net-vs-node.js-for-backend,代码行数:42,代码来源:Startup.cs

示例6: Log1

        private void Log1(IAppBuilder app)
        {
            ILogger logger = app.CreateLogger<Startup>();
            logger.WriteError("App is starting up");
            logger.WriteCritical("App is starting up");
            logger.WriteWarning("App is starting up");
            logger.WriteVerbose("App is starting up");
            logger.WriteInformation("App is starting up");

            int foo = 1;
            int bar = 0;

            try
            {
                int fb = foo / bar;
            }
            catch (Exception ex)
            {
                logger.WriteError("Error on calculation", ex);
            }
        }
开发者ID:TheFastCat,项目名称:OWINKatanaExamples,代码行数:21,代码来源:Startup.cs

示例7: Configuration

        public void Configuration(IAppBuilder app)
        {
            var logger = app.CreateLogger(GetType());

            app.SetDataProtectionProvider(new SharedSecretDataProtectionProvider(
                "af98j3pf98ja3fdopa32hr !!!! DO NOT USE THIS STRING IN YOUR APP !!!!",
                "AES",
                "HMACSHA256"));

            // example of a filter - writeline each request
            app.UseFilter(req => logger.WriteInformation(string.Format(
                "{0} {1}{2} {3}",
                req.Method,
                req.PathBase,
                req.Path,
                req.QueryString)));

            // example of a handler - all paths reply Hello, Owin!
            app.UseHandler(async (req, res) =>
            {
                res.ContentType = "text/plain";
                await res.WriteAsync("Hello, OWIN!");
            });
        }
开发者ID:RolandTG,项目名称:OwinSamples,代码行数:24,代码来源:Startup.cs

示例8: Configuration

        public void Configuration(IAppBuilder app)
        {
            var logger = app.CreateLogger("Katana.Sandbox.WebServer");

            logger.WriteInformation("Application Started");

            app.UseHandlerAsync(async (req, res, next) =>
            {
                req.TraceOutput.WriteLine("{0} {1}{2}", req.Method, req.PathBase, req.Path);
                await next();
                req.TraceOutput.WriteLine("{0} {1}{2}", res.StatusCode, req.PathBase, req.Path);
            });

            app.UseFormsAuthentication(new FormsAuthenticationOptions
            {
                AuthenticationType = "Application",
                AuthenticationMode = AuthenticationMode.Passive,
                LoginPath = "/Login",
                LogoutPath = "/Logout",
            });

            app.UseExternalSignInCookie();

            app.UseFacebookAuthentication(new FacebookAuthenticationOptions
            {
                SignInAsAuthenticationType = "External",
                AppId = "615948391767418",
                AppSecret = "c9b1fa6b68db835890ce469e0d98157f",
                // Scope = "email user_birthday user_website"
            });

            app.UseGoogleAuthentication();

            app.UseTwitterAuthentication("6XaCTaLbMqfj6ww3zvZ5g", "Il2eFzGIrYhz6BWjYhVXBPQSfZuS4xoHpSSyD9PI");

            app.UseMicrosoftAccountAuthentication("000000004C0EA787", "QZde5m5HHZPxdieV0lOy7bBVTbVqR9Ju");

            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions
            {
            });

            // CORS support
            app.UseHandlerAsync(async (req, res, next) =>
            {
                // for auth2 token requests, and web api requests
                if (req.Path == "/Token" || req.Path.StartsWith("/api/"))
                {
                    // if there is an origin header
                    var origin = req.GetHeader("Origin");
                    if (!string.IsNullOrEmpty(origin))
                    {
                        // allow the cross-site request
                        res.AddHeader("Access-Control-Allow-Origin", origin);
                    }

                    // if this is pre-flight request
                    if (req.Method == "OPTIONS")
                    {
                        // respond immediately with allowed request methods and headers
                        res.StatusCode = 200;
                        res.AddHeaderJoined("Access-Control-Allow-Methods", "GET", "POST");
                        res.AddHeaderJoined("Access-Control-Allow-Headers", "authorization");
                        // no further processing
                        return;
                    }
                }
                // continue executing pipeline
                await next();
            });

            app.UseOAuthAuthorizationServer(new OAuthAuthorizationServerOptions
            {
                AuthorizeEndpointPath = "/Authorize",
                TokenEndpointPath = "/Token",
                Provider = new OAuthAuthorizationServerProvider
                {
                    OnValidateClientCredentials = OnValidateClientCredentials,
                    OnValidateResourceOwnerCredentials = OnValidateResourceOwnerCredentials,
                },
            });

            var config = new HttpConfiguration();
            config.Routes.MapHttpRoute("Default", "api/{controller}");
            app.UseWebApi(config);
        }
开发者ID:tkggand,项目名称:katana,代码行数:85,代码来源:Startup.cs

示例9: ForceSslAlwaysMiddleware

 public ForceSslAlwaysMiddleware(OwinMiddleware next, IAppBuilder app, int sslPort)
     : base(next)
 {
     SslPort = sslPort;
     _logger = app.CreateLogger<ForceSslAlwaysMiddleware>();
 }
开发者ID:jlaanstra,项目名称:NuGetGallery,代码行数:6,代码来源:ForceSslAlwaysMiddleware.cs

示例10: MyOpenIDConnectAuthenticationMiddleware

 public MyOpenIDConnectAuthenticationMiddleware(OwinMiddleware next, IAppBuilder app,
     OpenIdConnectAuthenticationOptions options) : base(next, app, options)
 {
     _logger = app.CreateLogger<MyOpenIDConnectAuthenticationMiddleware>();
 }
开发者ID:vmfdesign,项目名称:Services,代码行数:5,代码来源:Settings.cs

示例11: Configuration

        public void Configuration(IAppBuilder app)
        {
            var logger = app.CreateLogger("Katana.Sandbox.WebServer");

            logger.WriteInformation("Application Started");

            app.Use(async (context, next) =>
            {
                context.Get<TextWriter>("host.TraceOutput").WriteLine("{0} {1}{2}", context.Request.Method, context.Request.PathBase, context.Request.Path);
                await next();
                context.Get<TextWriter>("host.TraceOutput").WriteLine("{0} {1}{2}", context.Response.StatusCode, context.Request.PathBase, context.Request.Path);
            });

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "Federation",
            });

            app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions()
            {
                AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Passive, // or active
                CallbackPath = new PathString("/signin-wsfed"), // optional constraint
                Wtrealm = "http://Katana.Sandbox.WebServer",
                MetadataAddress = "https://login.windows.net/cdc690f9-b6b8-4023-813a-bae7143d1f87/FederationMetadata/2007-06/FederationMetadata.xml",
                Notifications = new WsFederationAuthenticationNotifications()
                {
                    RedirectToIdentityProvider = new Func<RedirectToIdentityProviderNotification<WsFederationMessage>, Task>(context =>
                        {
                            context.ProtocolMessage.Wctx += "&foo=bar";
                            return Task.FromResult(0);
                        }),
                },
            });
            /*
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "Application",
                AuthenticationMode = AuthenticationMode.Passive,
                LoginPath = new PathString("/Login"),
                LogoutPath = new PathString("/Logout"),
            });

            app.SetDefaultSignInAsAuthenticationType("External");

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "External",
                AuthenticationMode = AuthenticationMode.Passive,
                CookieName = CookieAuthenticationDefaults.CookiePrefix + "External",
                ExpireTimeSpan = TimeSpan.FromMinutes(5),
            });

            app.UseFacebookAuthentication(new FacebookAuthenticationOptions
            {
                AppId = "615948391767418",
                AppSecret = "c9b1fa6b68db835890ce469e0d98157f",
                // Scope = "email user_birthday user_website"
            });

            app.UseGoogleAuthentication(clientId: "41249762691.apps.googleusercontent.com", clientSecret: "oDWPQ6e09MN5brDBDAnS_vd9");

            app.UseTwitterAuthentication("6XaCTaLbMqfj6ww3zvZ5g", "Il2eFzGIrYhz6BWjYhVXBPQSfZuS4xoHpSSyD9PI");

            app.UseMicrosoftAccountAuthentication("000000004C0EA787", "QZde5m5HHZPxdieV0lOy7bBVTbVqR9Ju");

            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions
            {
            });

            // CORS support
            app.Use(async (context, next) =>
            {
                IOwinRequest req = context.Request;
                IOwinResponse res = context.Response;
                // for auth2 token requests, and web api requests
                if (req.Path.StartsWithSegments(new PathString("/Token")) ||
                    req.Path.StartsWithSegments(new PathString("/api")))
                {
                    // if there is an origin header
                    var origin = req.Headers.Get("Origin");
                    if (!string.IsNullOrEmpty(origin))
                    {
                        // allow the cross-site request
                        res.Headers.Set("Access-Control-Allow-Origin", origin);
                    }

                    // if this is pre-flight request
                    if (req.Method == "OPTIONS")
                    {
                        // respond immediately with allowed request methods and headers
                        res.StatusCode = 200;
                        res.Headers.AppendCommaSeparatedValues("Access-Control-Allow-Methods", "GET", "POST");
                        res.Headers.AppendCommaSeparatedValues("Access-Control-Allow-Headers", "authorization");
                        // no further processing
                        return;
                    }
                }
                // continue executing pipeline
                await next();
            });
//.........这里部分代码省略.........
开发者ID:ricardodemauro,项目名称:katana-clone,代码行数:101,代码来源:Startup.cs

示例12: Configuration

        public void Configuration(IAppBuilder app)
        {
            var logger = app.CreateLogger("Katana.Sandbox.WebServer");

            logger.WriteInformation("Application Started");

            app.Use(async (context, next) =>
            {
                context.Get<TextWriter>("host.TraceOutput").WriteLine("{0} {1}{2}", context.Request.Method, context.Request.PathBase, context.Request.Path);
                await next();
                context.Get<TextWriter>("host.TraceOutput").WriteLine("{0} {1}{2}", context.Response.StatusCode, context.Request.PathBase, context.Request.Path);
            });

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "Application",
                // LoginPath = new PathString("/Account/Login"),
            });

            app.SetDefaultSignInAsAuthenticationType("External");

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "External",
                AuthenticationMode = AuthenticationMode.Active,
                CookieName = CookieAuthenticationDefaults.CookiePrefix + "External",
                ExpireTimeSpan = TimeSpan.FromMinutes(5),
            });

            app.UseFacebookAuthentication(new FacebookAuthenticationOptions
            {
                AppId = "454990987951096",
                AppSecret = "ca7cbddf944f91f23c1ed776f265478e",
                // Scope = "email user_birthday user_website"
            });

            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
            {
                ClientId = "1033034290282-6h0n78feiepoltpqkmsrqh1ngmeh4co7.apps.googleusercontent.com",
                ClientSecret = "6l7lHh-B0_awzoTrlTGWh7km",
            });

            app.UseTwitterAuthentication("6XaCTaLbMqfj6ww3zvZ5g", "Il2eFzGIrYhz6BWjYhVXBPQSfZuS4xoHpSSyD9PI");

            app.UseMicrosoftAccountAuthentication("000000004C0EA787", "QZde5m5HHZPxdieV0lOy7bBVTbVqR9Ju");

            // app.UseAspNetAuthSession();
            /*
            app.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                SessionStore = new InMemoryAuthSessionStore()
            });
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
            */
            app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions()
            {
                Wtrealm = "http://Katana.Sandbox.WebServer",
                MetadataAddress = "https://login.windows.net/cdc690f9-b6b8-4023-813a-bae7143d1f87/FederationMetadata/2007-06/FederationMetadata.xml",
            });
            /*
            app.UseOpenIdConnectAuthentication(new Microsoft.Owin.Security.OpenIdConnect.OpenIdConnectAuthenticationOptions()
            {
                // Change vdir to http://localhost:63786/
                // User [email protected]
                Authority = "https://login.windows-ppe.net/adale2etenant1.ccsctp.net",
                ClientId = "a81cf7a1-5a2d-4382-9f4b-0fa91a8992dc",
            });
            */
            /*
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions
            {
            });

            // CORS support
            app.Use(async (context, next) =>
            {
                IOwinRequest req = context.Request;
                IOwinResponse res = context.Response;
                // for auth2 token requests, and web api requests
                if (req.Path.StartsWithSegments(new PathString("/Token")) ||
                    req.Path.StartsWithSegments(new PathString("/api")))
                {
                    // if there is an origin header
                    var origin = req.Headers.Get("Origin");
                    if (!string.IsNullOrEmpty(origin))
                    {
                        // allow the cross-site request
                        res.Headers.Set("Access-Control-Allow-Origin", origin);
                    }

                    // if this is pre-flight request
                    if (req.Method == "OPTIONS")
                    {
                        // respond immediately with allowed request methods and headers
                        res.StatusCode = 200;
                        res.Headers.AppendCommaSeparatedValues("Access-Control-Allow-Methods", "GET", "POST");
                        res.Headers.AppendCommaSeparatedValues("Access-Control-Allow-Headers", "authorization");
                        // no further processing
                        return;
                    }
//.........这里部分代码省略.........
开发者ID:Kstal,项目名称:Microsoft.Owin,代码行数:101,代码来源:Startup.cs

示例13: ElmoMiddleware

 public ElmoMiddleware(OwinMiddleware next, IAppBuilder app, IErrorLog errorLog)
     : base(next)
 {
     this.errorLog = errorLog;
     logger = app.CreateLogger<ElmoMiddleware>();
 }
开发者ID:Eonix,项目名称:Elmo,代码行数:6,代码来源:ElmoMiddleware.cs

示例14: ContainerMiddleware

 public ContainerMiddleware(AppFunc nextFunc, IAppBuilder app)
 {
     _nextFunc = nextFunc;
     _app = app;
     _logger = app.CreateLogger<ContainerMiddleware>();
 }
开发者ID:dev-informatics,项目名称:DotNetDoodle.Owin.Dependencies,代码行数:6,代码来源:ContainerMiddleware.cs

示例15: MyCookieAuthenticationMiddleware

 public MyCookieAuthenticationMiddleware(OwinMiddleware next, IAppBuilder app, CookieAuthenticationOptions options)
     : base(next, app, options)
 {
     _logger = app.CreateLogger<CookieAuthenticationMiddleware>();
 }
开发者ID:dstrockis,项目名称:Katana-Sliding-Session,代码行数:5,代码来源:MyCookieAuthenticationMiddleware.cs


注:本文中的IAppBuilder.CreateLogger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。