Utilities.cs 925 B

123456789101112131415161718192021222324252627282930313233
  1. using Microsoft.Extensions.Logging;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. namespace Winsoft.GOV.XF.WebApi.WXCore.Helpers
  7. {
  8. public static class Utilities
  9. {
  10. static ILoggerFactory _loggerFactory;
  11. public static void ConfigureLogger(ILoggerFactory loggerFactory)
  12. {
  13. _loggerFactory = loggerFactory;
  14. }
  15. public static ILogger CreateLogger<T>()
  16. {
  17. if (_loggerFactory == null)
  18. {
  19. throw new InvalidOperationException($"{nameof(ILogger)} is not configured. {nameof(ConfigureLogger)} must be called before use");
  20. //_loggerFactory = new LoggerFactory().AddConsole().AddDebug();
  21. }
  22. return _loggerFactory.CreateLogger<T>();
  23. }
  24. public static string ContentRootPath { get; set; }
  25. }
  26. }