The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LoggerProvider.cs 763B

123456789101112131415161718192021222324252627282930
  1. using Microsoft.Extensions.Logging;
  2. using System;
  3. using System.Collections.Concurrent;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. using Teknik.Configuration;
  7. namespace Teknik.Logging
  8. {
  9. public class LoggerProvider : ILoggerProvider
  10. {
  11. private readonly Config _config;
  12. private readonly ConcurrentDictionary<string, Logger> _loggers = new ConcurrentDictionary<string, Logger>();
  13. public LoggerProvider(Config config)
  14. {
  15. _config = config;
  16. }
  17. public ILogger CreateLogger(string categoryName)
  18. {
  19. return _loggers.GetOrAdd(categoryName, name => new Logger(name, _config));
  20. }
  21. public void Dispose()
  22. {
  23. _loggers.Clear();
  24. }
  25. }
  26. }