You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, thanks a lot for the defacto standard dotnet logger that countless apps depend on.
Sorry for only getting to say this while contacting for a small-ish bug.
This bug is about how applying theme to redirected output seems to stop dotnet watch run from starting a browser if the dotnet app is a web application.
I'll use the template provided, just as headers so that I don't have to indent my input:
Your dotnet toolchain version, target framework, and operating system,
dotnet --info
.NET SDK:
Version: 8.0.204
Commit: c338c7548c
Workload version: 8.0.200-manifests.4b097a37
Runtime Environment:
OS Name: Mac OS X
OS Version: 14.4
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/8.0.204/
The current behavior
I have run the following steps:
mkdir RedirectedThemeSample
cd RedirectedThemeSample
dotnet new web
dotnet add package Serilog.AspNetCore --version 8.0.1
dotnet restore
Then I modified the "Program.cs" file to be:
using Serilog;using Serilog.Sinks.SystemConsole.Themes;varbuilder= WebApplication.CreateBuilder(args);// Only added part to the app other than `using`s
builder.Host.UseSerilog((context,services,configuration)=> configuration.WriteTo.Console(theme: AnsiConsoleTheme.Code, applyThemeToRedirectedOutput:true));varapp= builder.Build();
app.MapGet("/",()=>"Hello World!");
app.Run();
Then I ran:
dotnet watch run
The app raun, but the browser did not start, instead, I got a non blocking negative message in the console:
The file /Users/meligy/code/temp/RedirectedThemeSample/http:/localhost:5228 does not exist.
The only AnsiConsoleTheme that lets the browser open when I restart dotnet watch run is AnsiConsoleTheme.None, which loses all console colours. You also lose all console colours if you leave applyThemeToRedirectedOutput as false.
What you expect or want to happen instead
Ideally the browser would start, the console colouring would still work, and I wouldn't see the message that treats the URL as a file.
Additional Notes
It looks from the message as if the dotnet run is trying to start the URL as a process, and the redirection treats that as running an executable file or something. But I am not sure.
Again, thanks for all the great work.
Cheers,
The text was updated successfully, but these errors were encountered:
Meligy
changed the title
applyThemeToRedirectedOutput prevents starting ASP.NET Core browser
applyThemeToRedirectedOutput prevents dotnet watch run from starting browser for web apps
May 5, 2024
Is this a potential improvement to dotnet watch, i.e. ignoring ANSI escape sequences when looking for the Now listening on: log line?
IIRC, dotnet watch uses a simple regex to find this line, so although it could turn out to be a fairly odd looking regex, it might be reasonable just to extend it to ignore ANSI escapes. If it turns out that's the case it'd likely have benefits to other logging systems also :-)
Hello,
First, thanks a lot for the defacto standard dotnet logger that countless apps depend on.
Sorry for only getting to say this while contacting for a small-ish bug.
This bug is about how applying theme to redirected output seems to stop
dotnet watch run
from starting a browser if the dotnet app is a web application.I'll use the template provided, just as headers so that I don't have to indent my input:
The exact package id and version you're using
"Serilog.Sinks.Console" v5.0.0
Your
dotnet
toolchain version, target framework, and operating system,The current behavior
I have run the following steps:
mkdir RedirectedThemeSample cd RedirectedThemeSample dotnet new web dotnet add package Serilog.AspNetCore --version 8.0.1 dotnet restore
Then I modified the "Program.cs" file to be:
Then I ran:
The app raun, but the browser did not start, instead, I got a non blocking negative message in the console:
The only
AnsiConsoleTheme
that lets the browser open when I restartdotnet watch run
isAnsiConsoleTheme.None
, which loses all console colours. You also lose all console colours if you leaveapplyThemeToRedirectedOutput
asfalse
.What you expect or want to happen instead
Ideally the browser would start, the console colouring would still work, and I wouldn't see the message that treats the URL as a file.
Additional Notes
It looks from the message as if the
dotnet run
is trying to start the URL as a process, and the redirection treats that as running an executable file or something. But I am not sure.Again, thanks for all the great work.
Cheers,
The text was updated successfully, but these errors were encountered: