title: ASP.NET Core - Use both UseDeveloperExceptionPage() and custom logging
body: <p>I have the following code in my ASP.NET Core application to handle errors:</p>
  
  <pre><code>        if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
          else
          {
              app.UseExceptionHandler(builder =&gt;
              {
                  builder.Run(async context =&gt;
                  {
                      context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                      var loggingService = context.RequestServices.GetService&lt;ILoggingService&gt;();
                      var exceptionFeature = context.Features.Get&lt;IExceptionHandlerFeature&gt;();
                      if (exceptionFeature != null)
                      {
                          Exception ex = exceptionFeature.Error;
                          Console.Error.WriteLine(ex.Message + "   " + ex.StackTrace);
                          loggingService.Error(ex);
                      }
                  });
          }
  </code></pre>
  
  <p>However, when being in a <code>Development</code> environment, I would like to use both the <code>UseDeveloperExceptionPage()</code> and the custom error handling for DB logging. But it seems that this does not work (the <code>UseExceptionHandler()</code> disables the functionality of <code>UseDeveloperExceptionPage()</code>).</p>
  
  <p>Is there any way to achieve this, without writing the <code>UseDeveloperExceptionPage()</code> code form scratch?</p>