Skip to content

The working directory log message on app startup #85809

Description

@JamesNK

Description

#82445 added a new log message when an app starts (last line):

info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\Development\source\Benchmarks\src\BenchmarksApps\Grpc\BasicGrpc
info: Microsoft.Hosting.Lifetime[0]
      Current working directory is /. If Content root path is not set explicitly, then working directory is used by default.

This is a very prominent place for logging. Every ASP.NET Core app displays this log message by default when it starts. Exact thought needs to be put into what is logged here and it seems like it needs more work.

  • Weird casing. Why is "Content" capitalized in "If Content root ..."? It looks like a typo.
  • The log message is inconsistent with the other logging written during startup
  • Also, the meaning of the working directory value in logging is unclear. What does / mean? Should this be a full path?
  • Is information the right log level? Should this be displayed by default? The default ASP.NET Core log level is Information. If this is only useful for debugging then perhaps the Debug log level would be better. That reduces logs written on app start.
  • Needs unit tests

Reproduction Steps

Start an app with hosting, e.g. an aspnetcore app, with console logging. The log is written to the console:

Expected behavior

Log message is consistent with other logs on startup. Working directory value is easy to understand.

Actual behavior

info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\Development\source\Benchmarks\src\BenchmarksApps\Grpc\BasicGrpc
info: Microsoft.Hosting.Lifetime[0]
      Current working directory is /. If Content root path is not set explicitly, then working directory is used by default.

Hosting environment and content root path logs have the format Name: value. I would expect the current working directory to be the same, e.g. Working directory: XXX.

Also, this log seems the wrong place to add extra detail like If Content root path is not set explicitly, then working directory is used by default.. This logging is visible by default in every ASP.NET Core app that starts up. Only the most important detail should be logged here. I don't think that sentence meets the bar.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on May 5, 2023
  2. JamesNK commented on May 5, 2023

    @JamesNK
    MemberAuthor
  3. davidfowl commented on May 10, 2023

    @davidfowl
    Member

    I think we should revert this. It's unclear why this is useful information to show all of the time.

    cc @steveharter @ericstj

  4. removed
    untriagedNew issue has not been triaged by the area owner
    on May 10, 2023
  5. added this to the 8.0.0 milestone on May 10, 2023
  6. ericstj commented on May 10, 2023

    @ericstj
    Member

    Let's have another look at this, @steveharter. CC @pedrobsaila

  7. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on May 10, 2023
  8. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on May 10, 2023
  9. steveharter commented on May 10, 2023

    @steveharter
    Contributor

    The commit was reverted and the original issue was reopened.

  10. ghost locked as resolved and limited conversation to collaborators on Jun 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions