Answered by:
Failed Request Tracing Not Creating Log Files for .Net Core Site

Question
-
User-939035612 posted
I have a .Net Core website that works just fine when using localhost/IIS Express but when I publish it to IIS on the same machine I get a 500 error with nothing to go on. In the past I have successfully used IIS Failed Request Tracing to get more information from web forms sites. When I enable Failed Request Tracing in IIS for the .Net Core site everything looks good until I check the log folder. No Logs are ever created.
Is there something else that must be done for .Net Core to use Failed Request Tracing?
Monday, January 27, 2020 11:10 PM
Answers
-
User-939035612 posted
I just had to change the properties of the IISUrlRewrite.xml file. I set "copy to output directory" to "copy always"
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, February 6, 2020 8:51 AM
All replies
-
User475983607 posted
Is there something else that must be done for .Net Core to use Failed Request Tracing?Open the web.config on the server and change stdoutLogEnabled to true. Start the app, get the error, take a look at the logs folder in the app root.
<aspNetCore processPath="dotnet" arguments=".\Web.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
Monday, January 27, 2020 11:24 PM -
User-939035612 posted
Thanks, but even with the change my web.config looks different. I also am not sure where the logs\stdout can be found. There is not such folder in the application.
<?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=".\PostAlmostAnything.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" /> </system.webServer> </location> <system.webServer> <tracing> <traceFailedRequests> <add path="*"> <traceAreas> <add provider="ASP" verbosity="Verbose" /> <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" /> <add provider="ISAPI Extension" verbosity="Verbose" /> <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket,ANCM" verbosity="Verbose" /> </traceAreas> <failureDefinitions statusCodes="400-999" /> </add> </traceFailedRequests> </tracing> <modules> <add name="ApplicationRequestRouting" /> </modules> </system.webServer> </configuration>
Monday, January 27, 2020 11:39 PM -
User-782232518 posted
This only proves that you have a FRT rule created. You also need to enable FRT at site level.
Tuesday, January 28, 2020 5:52 AM -
User475983607 posted
CopBlaster
Thanks, but even with the change my web.config looks different. I also am not sure where the logs\stdout can be found. There is not such folder in the application.Sorry, forgot. Set the environment to development.
You can also start the application using the "dotnet myapp.dll" on the server if you have the SDK installed. This will bring up the console window and display any errors. In my experience a 500 error after deployment is a environment/configuration mistake.
Tuesday, January 28, 2020 12:11 PM -
User-939035612 posted
Adding those environmental variables changes nothing.
Monday, February 3, 2020 3:45 AM -
User-939035612 posted
how do you enable it on a site level then? the tutorials don't say to do anything more than enable it in iis
Monday, February 3, 2020 3:51 AM -
User-939035612 posted
Oops. I had dropped the main folder, recreated it, and had not added permissions back for the IIS user. Now I get this:
HTTP Error 500.30 - ANCM In-Process Start Failure
Common solutions to this issue:
- The application failed to start
- The application started but then stopped
- The application started but threw an exception during startup
Troubleshooting steps:
- Check the system event log for error messages
- Enable logging the application process' stdout messages
- Attach a debugger to the application process and inspect
For more information visit: <cite>https://go.microsoft.com/fwlink/?LinkID=2028265</cite>
Wednesday, February 5, 2020 10:30 PM -
User-939035612 posted
This new config file creates a log file finally but the log is empty and the browser just says "
An error occurred while starting the application.
"
<?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=".\PostAlmostAnything.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" /> </system.webServer> </location> </configuration> <!--ProjectGuid: de5d37a5-9ab4-4749-926a-7816d599ac55-->
Thursday, February 6, 2020 4:19 AM -
User-939035612 posted
FINALLY GOT A LOG, But it is confusing. I have an XML file in my project called IISUrlRewrite.xml but for some reason it does not exist when I publish it to IIS. Is there a way to tell visual studio to include that XML file as its own file without packing it up with everything else?
crit: Microsoft.AspNetCore.Hosting.Diagnostics[6]
Application startup exception
System.IO.FileNotFoundException: Could not find file 'C:\Users\me\Documents\postalmostanything\IISUrlRewrite.xml'.
File name: 'C:\Users\sulli\Documents\postalmostanything\IISUrlRewrite.xml'
at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path)
at System.IO.File.OpenText(String path)
at PostAlmostAnything.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in C:\Users\sulli\source\repos\PostAlmostAnything\PostAlmostAnything\Startup.cs:line 77
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.<UseStartup>b__2(IApplicationBuilder app)
at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Users\sulli\Documents\postalmostanything
info: Microsoft.Hosting.Lifetime[0]
Application is shutting down...Thursday, February 6, 2020 5:12 AM -
User-939035612 posted
I just had to change the properties of the IISUrlRewrite.xml file. I set "copy to output directory" to "copy always"
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, February 6, 2020 8:51 AM