简体   繁体   中英

No debug logfile created after adding in web.config for ASP.NET Core 3.1 MVC deployment

I have a problem that my ASP.NET Core 3.1 MVC web app unable to retrieve data from SQL Server after publishing in IIS Windows server. I want to see the log file to debug the error.

First I configure the web.config file to development mode.

<?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=".\BookListMVC.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" >
        <environmentVariables>
            <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
        </environmentVariables>
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 828f3e4a-8c05-4c79-8216-5b5d5358d740-->

I can't find any debug information inside web inspect.

After that I read the documentation in Microsoft https://learn.microsoft.com/en-us/as.net/core/host-and-deploy/iis/logging-and-diagnostics?view=as.netcore-7.0&viewFallbackFrom=as.netcore-3.1

and I have configured the web.config file:

<?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=".\BookListMVC.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess">
        <handlerSettings>
          <handlerSetting name="debugFile" value=".\logs\aspnetcore-debug.log" />
          <handlerSetting name="debugLevel" value="FILE,TRACE" />
        </handlerSettings>
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 828f3e4a-8c05-4c79-8216-5b5d5358d740-->

I suppose the log file will be generate after I load the deployed web app but it doesn't.

Local folder image

Can any expert help how to do debug for my web app?

On my local pc, the web app just does well in IISExpress localhost. The problem came after I publish and transfer it into a window server for deployment in a local.network.

Base on your code, you should turn stdoutlogenabled = true. Change it to false after troubleshooting.

I see your local folder image, you have to manually create the log folder. IIS does not generate this folder for you. You can refer to this for more detailed steps.

In addition, it may also appear that log file is not generated after the folder is created. Because IIS doesn't have permission to write to log folder.

  • Right click on the folder to Security.
  • Ensure IIS_IUSRS user have following permissions: read and execute, list, write.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM