Search code examples
asp.net-coreiisvisual-studio-2017asp.net-core-2.2

How to enable logging in published asp.net Core projects?


I published my asp.net core web api in a iis serveur , when i test in the browser the application i get an 502.5 error.

i searched on how to find a solution , i found that i need to enable logging by changing the stdoutLogEnabled="false" to true.

 <?xml version="1.0" encoding="utf-8"?>
    <configuration>
       <location path="." inheritInChildApplications="true">
       <system.webServer>
         <handlers>
         <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
  </handlers>
      <aspNetCore processPath="dotnet" arguments=".\WsAZProjet.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
      </system.webServer>
      </location>
    </configuration>
<!--ProjectGuid: baf7ef69-c0ff-4e36-b69c-71ad3fd869b9-->

i changed that in iis serveur and retested the app in the browser but i didn't get the log directory generated , so i think i should configure that in code and then republish the app ?

do you have an idea on how to enable logging for published apps ? should i restart iis for that to work ?

Update

After searching , i found here that i need to manualy create the logs folder , i did that and tested again the app , i get a log_stdout file under the folder but it is empty !!?


Solution

  • Solved , here the reason of the error :

    Incorrect proecessPath, missing PATH variable, or dotnet.exe access violation

    Browser: HTTP Error 502.5 - Process Failure

    Application Log: Failed to start process with commandline ‘“dotnet” .\my_application.dll’ (portable app) or ‘”.\my_application_Foo.exe”’ (self-contained app), ErrorCode = ‘0x80070002’.

    ASP.NET Core Module Log: Log file created but empty

    Troubleshooting: Check the processPath attribute on the element in web.config to confirm that it is dotnet for a portable application or .\my_application.exe for a self-contained application. For a portable application, dotnet.exe might not be accessible via the PATH settings. Confirm that C:\Program Files\dotnet\ exists in the System PATH settings. For a portable application, dotnet.exe might not be accessible for the user identity of the Application Pool. Confirm that the AppPool user identity has access to the C:\Program Files\dotnet directory.

    my processPath was set by me yesterday to C://ProgramFiles/dotnet.exe , changing that to just dotnet solve the issue and i get my log file informations now.