Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DockerLaunchAction seems to depend on log to start browser #323

Closed
ghogen opened this issue Jan 14, 2022 · 4 comments
Closed

DockerLaunchAction seems to depend on log to start browser #323

ghogen opened this issue Jan 14, 2022 · 4 comments
Assignees

Comments

@ghogen
Copy link

ghogen commented Jan 14, 2022

LaunchBrowser won't work if the log setting for
Microsoft.Hosting.Lifetime is not set to information. Visual studio seems to wait for Now listening on: http://[::]:80 before actually launching a browser. No warning or error is written anywhere. So it took my quite some time to figure this one out.

I added docker and docker-compose to an existing project. This project uses serilog with serilog request logging (UseSerilogRequestLogging) and all microsoft logging is set to Warning.

Originally entered by @mathysd as https://github.com/MicrosoftDocs/visualstudio-docs/issues/6441

@NCarlsonMSFT
Copy link
Member

@mathysd I've opened a PR to add docs for a work-around for this when debugging a single project in a container: MicrosoftDocs/visualstudio-docs#7541

Using the Launch Profile property launchBrowserTimeout you can specify a time to wait before starting the browser.

@dmikov
Copy link

dmikov commented May 9, 2023

Any update on that? We are using structured loging so we don't have that phrase at all it's broken out. So levels don't help.

@NCarlsonMSFT
Copy link
Member

@dmikov As now documented in: https://learn.microsoft.com/en-us/visualstudio/containers/container-launch-settings there is now a launch profile property launchBrowserTimeout. If you set that to 1, then after 1 second the browser will launch w/o waiting for the log output.

@waleed-alharthi
Copy link

Just in case a lost soul ends up here looking for a solution:

An example of setting logging levels in docker-compose.yml:

version: '3.4'

services:
  clamp:
    image: ${DOCKER_REGISTRY-}app
    ports:
      - "80:80"
      - "443:443"
    depends_on:
      - db
    environment:
      ASPNETCORE_ENVIRONMENT: Development #use Development to see full log messages, use Production to optimize for size and performance
      ConnectionStrings__DefaultConnection: "Host=clamp-db;Port=5432;Database=postgres;Username=postgres;Password=yes;Include Error Detail=true"
      Logging__LogLevel__Default: "Information" #use Debug to see full log messages, use Information to optimize for size and performance, also Warning, Error, Critical; Warning made browser launch much slower!
      Logging__LogLevel__Npgsql: "Warning" #i don't want to see all those EF Core messages
      SeedData: true
    build:
      context: .
      dockerfile: App/Dockerfile

Similar in appsettings.json or appsettings.Development.json

{
  "ConnectionStrings": {
    "DefaultConnection": "Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=yes;Include Error Detail=true" //database created when running compose project, maps to localhost
  },
  "DetailedErrors": true,
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Information", // If changed from "Information" browser launch becomes very slow
      "Npgsql": "Warning" // Set the desired log level here (Debug, Information, Warning, Error, etc.)
    }
  },
  "SeedData": true
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants