Identity Server 8.0.16 does not write logs to the file system


Description

Identity Server 8.0.16 does not write logs to the file system in on-prem, Azure App Service, and container deployments.

The issue was caused by updating the logging implementation – replacing the Serilog.Sinks.RollingFile with the Serilog.Sinks.File after the Serilog.Sinks.RollingFile was deprecated by the third party.

Solution

To enable logging to the file system, you can reintroduce the Serilog.Sinks.RollingFile by following these customization steps:

  1. Download and put Serilog.Sinks.RollingFile.dll in the root folder of the Sitecore Identity Server instance (the latest version is 3.3.0).
  2. In the \sitecorehost.xml file, update <DefaultLogger> to use RollingFile instead of File:
    ?xml version="1.0" encoding="utf-8"?>
    <Sitecore>
      <Logging>
        <Serilog>
          ...
            <DefaultLogger>
              <Name>RollingFile</Name>
              <Args>
                <pathFormat>logs\sts-{Date}.log</pathFormat>
                <outputTemplate>{Timestamp:o} [{Level:u3}] ({Application}/{MachineName}) {Message}{NewLine}{Exception}</outputTemplate>
              </Args>
            </DefaultLogger>
          ...
        </Serilog>
      </Logging>
    </Sitecore>
  3. Update the \Sitecore.IdentityServer.Host.deps.json file to have references to Serilog.Sinks.RollingFile. To do this, you can replace the existing \Sitecore.IdentityServer.Host.deps.json file in the root folder of the Identity Server instance with the following file: Sitecore.IdentityServer.Host.deps.json.

    Note: Make sure to back up the original \Sitecore.IdentityServer.Host.deps.json file before replacing it with the file above, so the changes can be reverted if necessary in the future.

  4. Restart the Identity Server.