Closed rkttu closed 2 months ago
For reference, here are the current dependency check results.
@rkttu I'm investigating this issue, and from what I'm seeing so far, on Windows specifically, the ASP.NET app runs but the output pane doesn't show any logs so you might feel like it has hung. But if you go to http://localhost:5678
(url from your example) in a web browser you should see the default welcome page. Please let me know if that's not what you're seeing.
I'm still digging deeper to understand why logs aren't showing up. I haven't encountered the UnauthorizedAccessException
error you described yet. Do you get the error randomly? In other words, is it seemingly random when you get the error vs when it runs without logs?
There is definitely something special about how the default ASP.NET Core logging provider works on Windows vs Linux/macOS. If you use the following code that implements a custom logger that explicitly logs to the Console, you will see the logs:
var builder = WebApplication.CreateBuilder();
builder.Logging.ClearProviders();
builder.Logging.AddProvider(new LoggerProvider());
var app = builder.Build();
app.UseWelcomePage();
await app.RunAsync("http://localhost:5678");
public class CustomLogger(string categoryName) : ILogger
{
private readonly string CategoryName = categoryName;
public IDisposable BeginScope<TState>(TState state)
{
return new NoopDisposable();
}
public bool IsEnabled(LogLevel logLevel)
{
return true;
}
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
string message = "";
if (formatter != null)
{
message += formatter(state, exception);
}
Console.WriteLine($"[{logLevel.ToString()[0..3].ToUpper()}] {CategoryName}: {message}");
}
private class NoopDisposable : IDisposable
{
public void Dispose()
{
}
}
}
public class LoggerProvider : ILoggerProvider
{
public ILogger CreateLogger(string categoryName)
{
return new CustomLogger(categoryName);
}
public void Dispose()
{
}
}
Still gathering more info about what they are doing internally that's different on Windows. From what I can tell so far, if ASP.NET detects that standard output is redirected the built-in logging provider(s) don't forward output to the redirected output, and instead direct it somewhere else, or maybe no where at all. I can't find the output in the Event Viewer either so its not being redirected there.
Inspecting the ConsoleLoggingProvider
source code confirms my suspicion. Working on a fix for next release.
When you write and run code using a code snippet called a webapp, unlike the macOS version, it takes a long time on Windows or fails to run with the following error messages
I think it's a process file occupancy issue, so I shut down and restart the NetPad, but that doesn't solve the problem. (After restarting the Windows, the problem remains the same.)
I don't know how to provide debugging information, so I'm just sharing what I'm seeing. If there is a way to get a detailed log, please let me know and I'll follow up.