本文整理汇总了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>();
}
示例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);
}
示例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);
}
示例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");
}
示例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!");
}
});
}
示例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);
}
}
示例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!");
});
}
示例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);
}
示例9: ForceSslAlwaysMiddleware
public ForceSslAlwaysMiddleware(OwinMiddleware next, IAppBuilder app, int sslPort)
: base(next)
{
SslPort = sslPort;
_logger = app.CreateLogger<ForceSslAlwaysMiddleware>();
}
示例10: MyOpenIDConnectAuthenticationMiddleware
public MyOpenIDConnectAuthenticationMiddleware(OwinMiddleware next, IAppBuilder app,
OpenIdConnectAuthenticationOptions options) : base(next, app, options)
{
_logger = app.CreateLogger<MyOpenIDConnectAuthenticationMiddleware>();
}
示例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();
});
//.........这里部分代码省略.........
示例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;
}
//.........这里部分代码省略.........
示例13: ElmoMiddleware
public ElmoMiddleware(OwinMiddleware next, IAppBuilder app, IErrorLog errorLog)
: base(next)
{
this.errorLog = errorLog;
logger = app.CreateLogger<ElmoMiddleware>();
}
示例14: ContainerMiddleware
public ContainerMiddleware(AppFunc nextFunc, IAppBuilder app)
{
_nextFunc = nextFunc;
_app = app;
_logger = app.CreateLogger<ContainerMiddleware>();
}
示例15: MyCookieAuthenticationMiddleware
public MyCookieAuthenticationMiddleware(OwinMiddleware next, IAppBuilder app, CookieAuthenticationOptions options)
: base(next, app, options)
{
_logger = app.CreateLogger<CookieAuthenticationMiddleware>();
}