title: How to inject ILogger<T> dependency to a service in ConfigureServices - .net core 2.0
body: <p>I have the following <code>MailService</code>:</p>
  
  <pre><code>public class MailService : IMailService
  {
      private readonly ILogger&lt;MailService&gt; _logger;
      private readonly SmtpClient _client;
  
      public MailService(ILogger&lt;MailService&gt; logger, SmtpClient client)
      {
          _logger = logger;
          _client = client;
      }
  
      public async Task Send(string to, string subject, string body)
      {
          var message = new MailMessage
          {
              Subject = subject,
              Body = body,
              IsBodyHtml = true,
              From = new MailAddress("info@domain.com")
          };
  
          message.To.Add(to);
  
          using (_client)
          {
              _logger.LogTrace($"Sending email from {message.From.Address} to {to}. Subject: {subject}");
              await _client.SendMailAsync(message);
          }
      }
  
  }
  </code></pre>
  
  <p>I would like to create this service using an implementation factory because I will read the smtp settings from configuration and supply the smtp client like the following in <code>Startup.cs</code>:</p>
  
  <pre><code>services.AddTransient&lt;IMailService&gt;(provider =&gt;
  {
      var mailService = new MailService(***LOGGER INSTANCE HERE***, new SmtpClient("127.0.0.1", 25));
      return mailService;
  });
  </code></pre>
  
  <p>Is there a way to grab a logger instance and supply that to the mail service?</p>