Sdk: After publish to IIS, app does not log to stdout

Created on 17 Mar 2017  路  14Comments  路  Source: dotnet/sdk

Steps to reproduce

Target 1.1.1 .net core VS2017. Deploy app to IIS using standard Program.cs--

```c#
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls("http://localhost:5001")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup()
.UseApplicationInsights()
.Build();

enable logging via published web.config file

```c#
stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout"

Expected behavior

Expect log\stdout_xxxx file to be created and updated when server errors occur.

Actual behavior

No file is created, no event in event viewer

Environment data

dotnet --info output:
N/A, production IIS machine

Most helpful comment

I was having this same problem. Verified that web.config had stdoutLogEnabled="true", that logs folder existed and app pool identity had write permissions but still no log file. After I manually recycled App Pool it started working - you you might want to try that

All 14 comments

@Eilon would you happen to know a better home for this issue.

@moozzyk does this look like an ASP.NET issue or an ANCM issue?

Does the folder exists? .\logs\stdout tells me they want to log somewhere in the application subfolder but it is neither created or can be published:

  • ANCM does not create the folder so if it does not exist nothing gets logged (https://github.com/aspnet/AspNetCoreModule/issues/30)

    • dotnet publish does not publish empty folders (https://github.com/dotnet/cli/issues/2911, https://github.com/Microsoft/msbuild/issues/1586)

Closing for now since we haven't had activity here in a while. Please, re-activate if the suggestions above do not work for you.

I don't think this issue is resolved. As an alternate, folders will need to be created manually.

@sujithkrish the documents have been updated with a workaround to be put into the csproj file: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/directory-structure

See https://github.com/aspnet/websdk/issues/273 and https://github.com/aspnet/AspNetCoreModule/issues/30 for the underlying issues.

You have to check the folderpermissions of the logs folder. If you are running inside IIS you have a application pool for the application.

You have to grant write permissions for the "IIS APPPOOL\" user on the logs folder.

I have everything "in place", including IIS APPPOOL, however, nothing is being outputted.
I am using .Net Core 2.1

I was having this same problem. Verified that web.config had stdoutLogEnabled="true", that logs folder existed and app pool identity had write permissions but still no log file. After I manually recycled App Pool it started working - you you might want to try that

I was facing this problem too, and for me worked replace the relative path ".\logs\stdout" to the physical of the same folder "D:\xpto\website\logs\stdout".
I didn't change any permission.

I got it to work after manually creating the directory logs.
As explained here

Another solution could be adding a target to the applications .csproj, instead of manually creating a folder. Like this:

  <Target Name="CreateLogsFolder" AfterTargets="Publish">
    <MakeDir Directories="$(PublishDir)logs"
              Condition="!Exists('$(PublishDir)logs')" />
  </Target>

I got it to work after manually creating the directory logs.
As explained here

If that solution actually worked (and it doesn't), we wouldn't be pulling our hair out trying to get IIS to do something as simple as logging something. Incidentally, even if you put in the absolute path, enable to true in web.config, and set permissions on the log folder, it STILL DOES NOT WORK!!! MADNESS, I tell you!

I also have this problem - publishing sites as web application under default web site on virtual machine and wishing to have two separate log subfolders: but can't make it working! But in my case I'm getting weird error (even if 'logs' folder is created): Could not start stdout file redirection to 'logs\stdout' with application base 'C:\inetpub\wwwroot\IdentityServer\'. ios_base::failbit set: iostream stream error. It is because by default 'write' permission is not given to IIS_IUSRS. So this also needs to be adjusted via target, I suppose... http://sedodream.com/2011/11/08/SettingFolderPermissionsOnWebPublish.aspx

Was this page helpful?
0 / 5 - 0 ratings