本文整理汇总了C#中ILoggerFactory.AddEventLog方法的典型用法代码示例。如果您正苦于以下问题:C# ILoggerFactory.AddEventLog方法的具体用法?C# ILoggerFactory.AddEventLog怎么用?C# ILoggerFactory.AddEventLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILoggerFactory
的用法示例。
在下文中一共展示了ILoggerFactory.AddEventLog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Debug;
var settings = new EventLogSettings
{
SourceName = "Log App",
Filter = (source, level) => level >= LogLevel.Information
};
loggerFactory.AddEventLog(settings);
app.UseIISPlatformHandler();
app.Run(async context =>
{
var myClass = context.RequestServices.GetService<MyClass>();
myClass.DoSomething(1);
myClass.DoSomething(20);
myClass.DoSomething(-20);
await context.Response.WriteAsync("Hello World!");
});
}
示例2: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddDebug();
loggerFactory.AddEventLog();
var logger = loggerFactory.CreateLogger("ToprakWeb");
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseErrorPage();
}
app.UseApplicationInsightsRequestTelemetry();
app.UseErrorHandler(
errorApp =>
{
var telemetryClient = new TelemetryClient();
errorApp.Run(
async context =>
{
context.Response.StatusCode = 200;
context.Response.ContentType = "text/html";
await context.Response.WriteAsync("<html><body>\r\n");
await
context.Response.WriteAsync(
"Beklenmiyen bir hata olustu.<br>\r\n");
var error = context.GetFeature<IErrorHandlerFeature>();
if (error != null)
{
// This error would not normally be exposed to the client
logger.LogCritical($"{error.Error.Message} \n {error.Error.StackTrace}");
}
await context.Response.WriteAsync("<br><a href=\"/\">Home</a><br>\r\n");
await context.Response.WriteAsync("</body></html>\r\n");
await context.Response.WriteAsync(new string(' ', 512)); // Padding for IE
});
});
app.UseApplicationInsightsExceptionTelemetry();
var adminEmails = this.config["adminEmails"];
var facebookAppId = this.config["FacebookAppId"];
if (string.IsNullOrEmpty(facebookAppId) && env.IsDevelopment())
{
facebookAppId = this.config["AppSettings:FacebookAppId"];
}
var facebookAppSecret = this.config["FacebookAppSecret"];
if (string.IsNullOrEmpty(facebookAppSecret) && env.IsDevelopment())
{
facebookAppSecret = this.config["AppSettings:FacebookAppSecret"];
}
app.UseToprakWebAuthentication(
"ToprakWeb",
(options) =>
{
options.FacebookAppId = facebookAppId;
options.FacebookAppSecret = facebookAppSecret;
options.GoogleClientId = this.config["AppSettings:GoogleClientId"];
options.GoogleClientSecret = this.config["AppSettings:GoogleClientSecret"];
options.AdminIds = adminEmails.Split(',');
});
app.UseDefaultFiles();
var staticFileOptions = new StaticFileOptions();
var typeProvider = new FileExtensionContentTypeProvider();
if (!typeProvider.Mappings.ContainsKey(".woff2"))
{
typeProvider.Mappings.Add(".woff2", "application/font-woff2");
}
staticFileOptions.ContentTypeProvider = typeProvider;
app.UseStaticFiles(staticFileOptions);
app.UseMvc();
app.UseApplicationInsightsExceptionTelemetry();
}