title: How do I get my custom ILogger implementation from ILogger in, for example a controller?
body: <p>I have a custom logger, I would like to create an extension method called </p>
  
  <pre><code>SetContext(uniqueKey, object) 
  </code></pre>
  
  <p>where I can set a property in my custom logger and log that context when logging a message.</p>
  
  <p>So the code would look like this</p>
  
  <pre><code>_logger
       .SetContext(User.Email(), User)
             .LogError(1, new Exception("foo foo foo"), "bleep Bloop");
  </code></pre>
  
  <p>The problem I seem to be facing is that the ILogger, returned via DI in my controller, and in turn used by my extension method is not actually my custom ILogger implementation.</p>
  
  <pre><code> public static ILogger SetContext(this ILogger logger, string uniqueUserIdentifier, object context)
      {
          var redisPublisherLogger = logger as RedisPublisherLogger;
  
          if (redisPublisherLogger == null)
          {
              return logger;
          }
  
          redisPublisherLogger.Context = new LoggingContext
          {
              ContextData = context,
              UniqueUserIdentifier = uniqueUserIdentifier
          };
  
          return logger;
      }
  </code></pre>
  
  <p>So is there anyway I can go about doing something like this, I'm trying to avoid overriding all the logging methods on ILogger.</p>
  
  <p>Any help would be appreciated!
  Thanks</p>