IIS has some options to control whether detailed or custom error messages are shown when error occurs.

All following elements shall be put under <configuration> element in web.config file. For global config, refer to %SystemRoot%\System32\inetsrv\config\applicationHost.config file.

AppCmd.exe is the single command line tool for managing IIS 7 and above, located at %SystemRoot%\System32\inetsrv\appcmd.exe.

IIS: Show detailed errors

system.webServer/httpErrors

The <httpErrors> element allows you to configure custom error messages for your Web site or application.

Feature - IIS - Error Pages

Feature - IIS - Error Pages - Edit

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors errorMode="Detailed" />
    </system.webServer>
</configuration>
appcmd set config "Default Web Site" /section:system.webServer/httpErrors /errorMode:Detailed

Available errorMode values are DetailedLocalOnly, Custom and Detailed. Default: DetailedLocalOnly.

system.web/customErrors

Provides information about custom error messages for an ASP.NET application.

Feature - ASP.NET - .NET Error Pages

Feature - ASP.NET - .NET Error Pages - Edit

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <customErrors mode="Off" />
    </system.web>
</configuration>
appcmd set config "Default Web Site" /section:system.web/customErrors /mode:Off

Available mode values are RemoteOnly, On and Off. Default: RemoteOnly.

system.runtime.remoting/customErrors

Indicates whether the server channels in this application domain return filtered or complete exception information to local or remote callers.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.runtime.remoting>
        <customErrors mode="Off" />
    </system.runtime.remoting>
</configuration>

Available mode values are RemoteOnly, On and Off. Default: RemoteOnly.

Note: <system.runtime.remoting> config section is legacy, and has no AppCmd or IIS Manager support.

IIS: Failed Request Tracing Rules

Microsoft Docs

Feature - IIS - Failed Request Tracing Rules

Feature - IIS - Failed Request Tracing Rules - Edit Site

Feature - IIS - Failed Request Tracing Rules - Add Rule

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <tracing>
            <traceFailedRequests>
                <add path="*">
                    <traceAreas>
                        <add provider="ASP" verbosity="Verbose" />
                        <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
                        <add provider="ISAPI Extension" verbosity="Verbose" />
                        <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket" verbosity="Verbose" />
                    </traceAreas>
                    <failureDefinitions statusCodes="500" />
                </add>
            </traceFailedRequests>
        </tracing>
    </system.webServer>
</configuration>
appcmd set site "Default Web Site" -traceFailedRequestsLogging.enabled:"true" /commit:apphost

appcmd set config "Default Web Site" -section:system.webServer/tracing/traceFailedRequests /+"[path='*']"
appcmd set config "Default Web Site" -section:system.webServer/tracing/traceFailedRequests /+"[path='*'].traceAreas.[provider='ASP',verbosity='Verbose']"
appcmd set config "Default Web Site" -section:system.webServer/tracing/traceFailedRequests /+"[path='*'].traceAreas.[provider='ASPNET',areas='Infrastructure,Module,Page,AppServices',verbosity='Verbose']"
appcmd set config "Default Web Site" -section:system.webServer/tracing/traceFailedRequests /+"[path='*'].traceAreas.[provider='ISAPI Extension',verbosity='Verbose']"
appcmd set config "Default Web Site" -section:system.webServer/tracing/traceFailedRequests /+"[path='*'].traceAreas.[provider='WWW Server',areas='Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket',verbosity='Verbose']"
appcmd set config "Default Web Site" -section:system.webServer/tracing/traceFailedRequests /[path='*'].failureDefinitions.statusCodes:"500"

Enable log for .NET Assembly binding

reg add HKLM\Software\Microsoft\Fusion /v EnableLog /t REG_DWORD /d 1 /f

To turn on Fusion Logging, a restart of World Wide Web Publishing Service (W3SVC) is required.

Assembly binding logging turned OFF:

Assembly binding logging is turned OFF.

Assembly binding logging turned ON:

Assembly load trace