why log show 2 times request
Code:
public void ConfigureLogInline(IApplicationBuilder app, ILoggerFactory loggerfactory)
{
loggerfactory.AddConsole(minLevel: LogLevel.Information);
var logger = loggerfactory.CreateLogger("LogInline");
app.Use(async (context, next) =>
{
logger.LogInformation("Handling request.");
await next.Invoke();
logger.LogInformation("Finished handling request.");
});
app.Run(async context =>
{
await context.Response.WriteAsync("Hello from LogInline");
});
}
request url: http://localhost:5000/maptest
response in web command is
info: Microsoft.AspNet.Hosting.Internal.HostingEngine[1]
Request starting HTTP/1.1 GET http://localhost:5000/maptest
info: Microsoft.AspNet.Hosting.Internal.HostingEngine[1]
Request starting HTTP/1.1 GET http://localhost:5000/maptest
info: LogInline[0]
Handling request.
info: LogInline[0]
Handling request.
info: LogInline[0]
Finished handling request.
info: LogInline[0]
Finished handling request.
info: Microsoft.AspNet.Hosting.Internal.HostingEngine[2]
Request finished in 0.0266ms 200
info: Microsoft.AspNet.Hosting.Internal.HostingEngine[2]
Request finished in 0.0266ms 200
why???
Could you please share with us the complete project that reproduces the issue so we can take a look? Thanks!
@danroth27 source at https://github.com/blueskybcl/ContosoBooks/
source at https://github.com/blueskybcl/ContosoBooks/
2016-01-12
a364711322
发件人:Daniel Roth [email protected] 发送时间:2016-01-12 01:53 主题:Re: [Mvc] why log show 2 times request (#3887) 收件人:"aspnet/Mvc"[email protected] 抄送:"blueskybcl"[email protected]
Could you please share with us the complete project that reproduces the issue so we can take a look? Thanks! — Reply to this email directly or view it on GitHub.
Looks like this code adds the Console logger twice: https://github.com/blueskybcl/ContosoBooks/blob/master/Startup.cs#L39 https://github.com/blueskybcl/ContosoBooks/blob/master/Startup.cs#L81
Thank you.
2016-01-14
a364711322
发件人:Daniel Roth [email protected] 发送时间:2016-01-14 01:47 主题:Re: [Mvc] why log show 2 times request (#3887) 收件人:"aspnet/Mvc"[email protected] 抄送:"blueskybcl"[email protected]
Looks like this code adds the Console logger twice: https://github.com/blueskybcl/ContosoBooks/blob/master/Startup.cs#L39 https://github.com/blueskybcl/ContosoBooks/blob/master/Startup.cs#L81 — Reply to this email directly or view it on GitHub.