Mvc icon indicating copy to clipboard operation
Mvc copied to clipboard

why log show 2 times request

Open blueskybcl opened this issue 10 years ago • 5 comments

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???

blueskybcl avatar Jan 08 '16 00:01 blueskybcl

Could you please share with us the complete project that reproduces the issue so we can take a look? Thanks!

danroth27 avatar Jan 11 '16 17:01 danroth27

@danroth27 source at https://github.com/blueskybcl/ContosoBooks/

blueskybcl avatar Jan 12 '16 07:01 blueskybcl

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.

blueskybcl avatar Jan 12 '16 07:01 blueskybcl

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

danroth27 avatar Jan 13 '16 17:01 danroth27

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.

blueskybcl avatar Jan 14 '16 00:01 blueskybcl