Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Logger is disposed too soon #984

Closed
halter73 opened this issue Mar 23, 2017 · 3 comments
Closed

Logger is disposed too soon #984

halter73 opened this issue Mar 23, 2017 · 3 comments
Assignees

Comments

@halter73
Copy link
Member

The logger is shutdown before KestrelServer is disposed causing exceptions during logging. It seems to be related to aspnet/Logging#563, but @pakrym suggested the issue might be in WebHost.Dispose().

Unhandled Exception: System.AggregateException: An error occurred while writing to logger(s). (The collection has been marked as complete with regards to additions.) ---> System.InvalidOperationException: The collection has been marked as complete with regards to additions.

   at System.Collections.Concurrent.BlockingCollection`1.TryAddWithNoTimeValidation(T item, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Microsoft.Extensions.Logging.Console.Internal.ConsoleLoggerProcessor.EnqueueMessage(LogMessageEntry message)
   at Microsoft.Extensions.Logging.Console.ConsoleLogger.WriteMessage(LogLevel logLevel, String logName, Int32 eventId, String message, Exception exception)
   at Microsoft.Extensions.Logging.Console.ConsoleLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelTrace.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter) in C:\Users\shalter\dev\Universe\KestrelHttpServer\src\Microsoft.AspNetCore.Server.Kestrel\Internal\Infrastructure\KestrelTrace.cs:line 192
   at Microsoft.Extensions.Logging.LoggerExtensions.LogCritical(ILogger logger, String message, Object[] args)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.Dispose() in C:\Users\shalter\dev\Universe\KestrelHttpServer\src\Microsoft.AspNetCore.Server.Kestrel\Internal\KestrelEngine.cs:line 65
   at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Dispose() in C:\Users\shalter\dev\Universe\KestrelHttpServer\src\Microsoft.AspNetCore.Server.Kestrel\KestrelServer.cs:line 236
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.Dispose()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.Dispose()
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host, CancellationToken token, String shutdownMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at SampleApp.Startup.Main(String[] args) in C:\Users\shalter\dev\Universe\KestrelHttpServer\samples\SampleApp\Startup.cs:line 74
@Tratcher
Copy link
Member

#947 should handle this.

@cesarblum
Copy link
Contributor

cesarblum commented Mar 27, 2017

Will verify and close if not reproed.

For whatever reason I thought #947 was a PR 😛

@cesarblum cesarblum self-assigned this Mar 27, 2017
@muratg muratg added this to the 2.0.0 milestone Mar 28, 2017
@cesarblum cesarblum removed their assignment Mar 28, 2017
@muratg muratg added 3 - Done and removed 1 - Ready labels Apr 13, 2017
@muratg
Copy link

muratg commented Apr 13, 2017

Done in #947

@muratg muratg closed this as completed Apr 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants