Troubleshooting an ASP.NET Core Apps

Enabling ASP.NET Core stdout log

Some errors that occur during application startup prevent Application logging framework from working.

In such cases, enabling the ASP.NET Core stdout log usually helps to diagnose the issue.

Important:
Disable stdout logging when troubleshooting is complete.

To enable ASP.NET Core stdout log:

  1. Navigate to the application's publish root folder.
  2. If the logs folder isn't present, create the folder on app root or an absolute path ex: C:\Logs (this should be the log volume hostPath in case you run your app on Docker).
  3. Edit the web.config file. Set stdoutLogEnabled to true and change the stdoutLogFile path to point to the logs folder (for example, .\logs\stdout or the absolute path C:\Logs\stdout). stdout in the path is the log file name prefix. A timestamp, process id, and file extension are added automatically when the log is created. Using stdout as the file name prefix, a typical log file is named C:\Logs\stdout_20180205184032_5412.log.
  4. Ensure your application pool's identity has write permissions to the logs folder.
  5. Save the updated web.config file.
  6. Make a request to the app.
  7. Navigate to the logs folder. Find and open the most recent stdout log.
  8. Study the log for errors.

To disable it after troubleshooting is complete:

  1. Edit the web.config file.
  2. Set stdoutLogEnabled to false.
  3. Save the file.

See how web.config should look like:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\{AppName}.dll" stdoutLogEnabled="true" stdoutLogFile="C:\Logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>