Make TestApplicationErrorLogger thread-safe

This commit is contained in:
Stephen Halter 2016-11-21 12:09:47 -08:00
parent 2016578f4e
commit b2d45c3dd0
1 changed files with 2 additions and 2 deletions

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Collections.Generic; using System.Collections.Concurrent;
using System.Linq; using System.Linq;
using Microsoft.AspNetCore.Server.Kestrel.Internal; using Microsoft.AspNetCore.Server.Kestrel.Internal;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Testing
// Application errors are logged using 13 as the eventId. // Application errors are logged using 13 as the eventId.
private const int ApplicationErrorEventId = 13; private const int ApplicationErrorEventId = 13;
public List<LogMessage> Messages { get; } = new List<LogMessage>(); public ConcurrentBag<LogMessage> Messages { get; } = new ConcurrentBag<LogMessage>();
public int TotalErrorsLogged => Messages.Count(message => message.LogLevel == LogLevel.Error); public int TotalErrorsLogged => Messages.Count(message => message.LogLevel == LogLevel.Error);