ASP.NET Core Module configuration examples

Programming, error messages and sample code > ASP.NET

Log creation and redirection

To save logs, you must create the logs directory. The ASP.NET Core Module can redirect stdoutand stderr logs to disk by setting the stdoutLogEnabled and stdoutLogFile attributes of theaspNetCore element. Logs are not rotated (unless process recycling/restart occurs). It is the responsibilty of the hoster to limit the disk space the logs consume.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!--
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
  -->
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\WebApplication1.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
  </system.webServer>
</configuration>
 

Setting environment variables

The ASP.NET Core Module allows you specify environment variables for the process specified in the processPath setting by specifying them in environmentVariables child attribute to theaspNetCore attribute.

<aspNetCore processPath="dotnet"
            arguments=".\MyApp.dll"
            stdoutLogEnabled="true"
            stdoutLogFile=".\logs\stdout">
      <environmentVariables>
        <environmentVariable name="DEMO" value="demo_value" />
      </environmentVariables>
    </aspNetCore>
 
More https://docs.asp.net/en/latest/hosting/aspnet-core-module.html