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
dotnet list package --include-transitive
Project 'RedirectedThemeSample' has the following package references
[net8.0]:
Top-level Package Requested Resolved
> Serilog.AspNetCore 8.0.1 8.0.1
Transitive Package Resolved
> Microsoft.Extensions.Configuration.Abstractions 8.0.0
> Microsoft.Extensions.Configuration.Binder 8.0.0
> Microsoft.Extensions.DependencyInjection 8.0.0
> Microsoft.Extensions.DependencyInjection.Abstractions 8.0.0
> Microsoft.Extensions.DependencyModel 8.0.0
> Microsoft.Extensions.Diagnostics.Abstractions 8.0.0
> Microsoft.Extensions.FileProviders.Abstractions 8.0.0
> Microsoft.Extensions.Hosting.Abstractions 8.0.0
> Microsoft.Extensions.Logging 8.0.0
> Microsoft.Extensions.Logging.Abstractions 8.0.0
> Microsoft.Extensions.Options 8.0.0
> Microsoft.Extensions.Primitives 8.0.0
> Serilog 3.1.1
> Serilog.Extensions.Hosting 8.0.0
> Serilog.Extensions.Logging 8.0.0
> Serilog.Formatting.Compact 2.0.0
> Serilog.Settings.Configuration 8.0.0
> Serilog.Sinks.Console 5.0.0
> Serilog.Sinks.Debug 2.0.0
> Serilog.Sinks.File 5.0.0
> System.Diagnostics.DiagnosticSource 8.0.0
> System.Text.Encodings.Web 8.0.0
> System.Text.Json 8.0.0
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;
var builder = 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)
);
var app = builder.Build();
app.MapGet("/", () => "Hello World!");
app.Run();
Then I ran:
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,
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 runfrom 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
dotnettoolchain 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 restoreThen 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
AnsiConsoleThemethat lets the browser open when I restartdotnet watch runisAnsiConsoleTheme.None, which loses all console colours. You also lose all console colours if you leaveapplyThemeToRedirectedOutputasfalse.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 runis 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,