title: Dependency Injection on static method in ASP .Net Core
body: <p>I have registered the implementation of my logger in ServiceCollection in the start up:</p>
  
  <pre class="lang-cs prettyprint-override"><code>services.AddTransient(typeof(ILogger&lt;&gt;), typeof(GenericLogger&lt;&gt;));
  </code></pre>
  
  <p>Usually, I do this to inject using Constructor:</p>
  
  <pre class="lang-cs prettyprint-override"><code>class DynamoEventProcessor
  {
      private readonly IRepository _repository;
      private readonly IDogStatsd _dogStatsd;
      private readonly ILogger&lt;DynamoEventProcessor&gt; _logger;
  
      public DynamoEventProcessor(IRepository repository, IDogStatsd dogStatsd, ILogger&lt;DynamoEventProcessor&gt; logger)
      {
          _repository = repository;
          _dogStatsd = dogStatsd;
          _logger = logger;
      }
  }
  </code></pre>
  
  <p>But I have a class where there is no constructor:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class ProfileContent
  {
      public MemoryStream Content { get; set; }
      public string ContentAlgorithm { get; set; }
      public List&lt;Dictionary&lt;string, AttributeValue&gt;&gt; DataKeys { get; set; }
      public long ExpiresUtc { get; set; }
      public long Version { get; set; }
      public long Deleted { get; set; }
  
      public static Dictionary&lt;string, EncryptedDataAndKeys&gt; GetEncryptedDataAndKeys(Dictionary&lt;string, Dictionary&lt;string, AttributeValue&gt;&gt; profileContentAttributes)
      {
          _logger.LogInformation("Available Keys: " + KeysAsString(keyList));
          _logger.LogInformation("AccountId missing Coporate Data: " + _converter.GetValueFromAttributeValue(attributes["AccountId"]).ToString());
          var encryptedDataAndKeys = new Dictionary&lt;string, EncryptedDataAndKeys&gt;();
  
          foreach (var item in profileContentAttributes)
          {
              encryptedDataAndKeys.Add(item.Key, GetEncryptedDataAndKey(item.Value));
          }
  
          return encryptedDataAndKeys;
      }
  }
  </code></pre>
  
  <p>My <code>_logger</code> failed here due to null. I understand the problem, that I didn't inject it properly. How can I inject it when I use it in static method without instantiating an object?</p>