如何关闭 ASP.NET 对每个请求所做的日志记录,例如。
INFO 09:38:41用户配置文件可用。使用“ C: Users xxxx xxxx AppData Local ASP.NET DataProtection-Keys”作为密钥存储库,使用 Windows DPAPI 对静止的密钥进行加密。
调试09:38:41主机开始
调试09:38:41主机开始
请求启动 HTTP/1.1 GET < a href = “ HTTP://localhost: 23369/”rel = “ norefrer”> HTTP://localhost:23369/
INFO 09:38:41请求启动 HTTP/1.1 DEBUG http://localhost:23369/ text/html 不支持调试09:38:41调试请求
DEBUG 09:38:41请求路径/与支持的文件类型不匹配
DEBUG 09:38:41 Request 成功地匹配了名称为‘ default’和模板为‘{ controller = Home }/{ action = Index }/{ id? }’的路由。 DEBUG 09:38:41 Request 成功地匹配了名称为‘ default’和模板为‘{ controller = Home }/{ action = Index }/{ id? }’的路由。 调试09:38:41执行动作论坛。控制器。家庭控制器。索引
调试09:38:41执行动作论坛。控制器。家庭控制器。索引
INFO 09:38:41正在执行动作方法 Forums. Controllers. HomeController. 带参数的索引()-ModelState 是有效的’
执行动作方法论坛。控制器。家控制器。索引
..
我还不知道怎么关掉这个登录。
这是我在 Startup
类中的 Configure
方法:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddProvider(new Log4NetProvider());
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
try
{
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
.CreateScope())
{
serviceScope.ServiceProvider.GetService<ApplicationDbContext>()
.Database.Migrate();
}
}
catch { }
}
app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
app.UseStaticFiles();
app.UseIdentity();
// To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
这是我的 project.json 文件:
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"log4net": "2.0.5",
"Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { }
},
更新:
我的 log4net 提供者从这里获取了一个 href = “ http://dotnetLiberty.com/index.php/2015/11/09/asp-net-5-logging-with-log4net/”rel = “ noReferrer”>