Skip to content

Commit

Permalink
Merge pull request #261 from geekyed/5.x
Browse files Browse the repository at this point in the history
Fixing an issue caused by the usage of a non thread safe Dictionary.
  • Loading branch information
pardel authored Nov 23, 2021
2 parents dfa8be7 + 2558b4b commit da8a1f0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Vonage/Logger/LogProvider.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System;

namespace Vonage.Logger
{
public class LogProvider
{
private static IDictionary<string, ILogger> _loggers = new Dictionary<string, ILogger>();
private static IDictionary<string, ILogger> _loggers = new ConcurrentDictionary<string, ILogger>();
private static ILoggerFactory _loggerFactory = new LoggerFactory();

public static void SetLogFactory(ILoggerFactory factory)
Expand All @@ -20,7 +22,7 @@ public static ILogger GetLogger(string category)
{
if (!_loggers.ContainsKey(category))
{
_loggers[category] = _loggerFactory?.CreateLogger(category)?? NullLogger.Instance;
_loggers[category] = _loggerFactory?.CreateLogger(category) ?? NullLogger.Instance;
}
return _loggers[category];
}
Expand Down

0 comments on commit da8a1f0

Please sign in to comment.