title: Implement full logging in Integration Test
body: <p>I'm creating a new app in .Net Core 3.1.</p>
  <p>I have the database created, and now I'm working on the business logic, which is in a collection of services. Before I start to create the API or the UI (ie: any web-app type project), I want to 100% get all of the Data Access and Services working as expected first... including logging. To make sure this is all working together as it should, I want to create some integration tests.</p>
  <p>The problem I am running into is I am REALLY struggling with how to get logging working. Every tutorial, document, and all of the examples I can find assume you have a <code>Program.cs</code> and <code>Startup.cs</code>.</p>
  <p><strong>NOTE 1:</strong> I want the logging to work just as it would in production, which means all the way to SQL. No mocking. No substitution. No replacing.</p>
  <p><strong>NOTE 2:</strong> I don't care so much about logging from the test. I want logging to work <em>in the service</em>.</p>
  <p>Here is an example of an integration test (xUnit) class that I have so far. It's working but has no logging.</p>
  <pre><code>namespace MyApp.Test
  {
      public class Startup
      {
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddTransient&lt;IAccountService, AccountService&gt;();
              services.AddTransient&lt;IAppSettings, AppSettings&gt;();
          }
      }
  
      public class AccountServiceTests
      {
          private readonly IAccountService _account;
          private readonly IAppSettings _settings;
  
          public AccountServiceTests(IAccountService account, IAppSettings settings)
          {
              _account = account;
              _settings = settings;
          }
  
          [Fact]
          public async Task AccountService_CreateAccount()
          {
              Account account = new Account( {...} );
              bool result = _account.CreateAccount(account);
              Assert.True(result);
          }
      }
  }
  </code></pre>
  <p>The DI is working because of NuGet <a href="https://github.com/pengweiqhca/Xunit.DependencyInjection" rel="nofollow noreferrer">Xunit.DependencyInjection</a>.</p>
  <p>And then in the service...</p>
  <pre><code>public class AccountService : ServiceBase, IAccountService
  {
          protected readonly ILogger _logger;
          protected readonly IAppSettings _settings;
  
          public AccountService(ILogger&lt;AccountService&gt; logger, IAppSettings settings) 
          {
              _logger = logger;
              _settings = settings;
          }
  
          public bool CreateAccount()
          {
              // do stuff
              _logger.Log(LogLevel.Information, &quot;An account was created.&quot;); // I WANT THIS TO END UP IN SQL, EVEN FROM THE TEST.
          }
  }
  </code></pre>
  <p>The test passes, and the account is properly created in the database. However, as best as I can tell, this line doesn't do anything:</p>
  <pre><code>_logger.Log(LogLevel.Information, &quot;An account was created.&quot;);
  </code></pre>
  <p>I understand why. <code>Microsoft.Extensions.Logging</code> is just an abstraction, and I need to implement some concrete logging (with SeriLog or Log4Net, etc.)</p>
  <p>This brings me back to my original question: For the life of me, I can not find a working tutorial on how to get either one of those (SeriLog or Log4Net) working within an integration test (xUnit in particular).</p>
  <p>Any help, or point in the right direction, or a link to a tutorial would be wonderful.  Thanks.</p>