-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Describe the bug
When trying to redirect Console output to a text file, the stdoutLogFile is created, but is always empty.
The following settings are present in the projects ( ASP.NET Core Web Application) web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile="D:\temp\website3_log" hostingModel="inprocess">
<handlerSettings>
<handlerSetting name="debugFile" value="D:\\temp\\website3_debug_log" />
<handlerSetting name="debugLevel" value="FILE,INFO" />
</handlerSettings>
<environmentVariables>
<environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44383" />
<environmentVariable name="COMPLUS_ForceENC" value="1" />
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
The debugFile is created and log entries are present without issue.
The stdoutLogFile is created, but remains empty.
Questions:
- WHY is the stdoutLogFile always empty? It appears that when Console.WriteLine( "this should be in the log file" ) statements are executed within code, the WriteLine method is NOT redirecting output to the stdoutLogFile.
To Reproduce
Steps to reproduce the behavior:
- Using Visual Studio
- Click on "Create a new project"
- Select ASP.NET Core Web Application -> Next
- Enter project name, Location, Solution Name -> Create
- Add web.config to the project and set the stdoutLogEnabled="true"
- Set the stdoutLogFile attribute to the path of the log file.
Expected behavior
When Console.WriteLine() statements are executed, it is expected that the Console output is redirected to the stdoutLogFile file (or, at least one ASSUME's that would be the case -- can this be confirmed anywhere in the docs? -- I have yet to find anything!!).
Additional context
Also looking for details with regard to the schema of the following files:
-
web.config - where do we find the complete schema? Where do we find the complete schema that explains all valid entries that may appear in this file and the effect of each entry.
-
launchsettings.json - again, where do we find the complete schema that explains all valid entries that may appear in this file and the effect of each entry.
-
This issue was raised within the documentation at: Console log redirection needs working example AspNetCore.Docs#15080
Finally, not sure if this would be possible, but a more consistent approach to Console logging (redirection) might be to include a "handler" for Console output, for example:
<handlerSettings>
<handlerSetting name="debugFile" value="D:\\temp\\website3_debug_log" />
<handlerSetting name="debugLevel" value="FILE,INFO" />
<handlerSetting name="consoleFile" value="D:\\temp\\website3_console_log" />
</handlerSettings>
Adding a handler for Console output would be more consistent than the stdoutLogFile and stdoutLogEnabled attributes on the aspNetCore node.