Skip to content

Allow configuring W3CLogging to write to stdout #42489

Open
@ajkonkol

Description

@ajkonkol

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I am trying to configure the W3CLogging to write to stdout instead of a file on disk, since this is a best practice when running applications in a Docker container. I tried the following, but it doesn't quite work because it ultimately is trying to write to /dev/stdout/w3clog-20220629.0000.txt, for example, which isn't a valid location on Linux:

builder.Services.AddW3CLogging(logging =>
{
    logging.LogDirectory = "/dev/stdout";
});

Is there some way to have the W3C logs write to stdout instead of a file on disk?

Describe the solution you'd like

It seems like if we could configure the W3CLogger to not rotate files but always write to a specific "file", that would solve this for us. Something like this, perhaps:

builder.Services.AddW3CLogging(logging =>
{
    // proposed:  set a static file name that doesn't automatically append dates or rotate
    logging.StaticFileName = "/dev/stdout";
});

By setting StaticFileName, this would override the normal behavior you get when setting FileName and LogDirectory, and would ignore RetainedFileCountLimit and FileSizeLimit. New logs would just be written directly to whatever file you defined by StaticFileName, which in our case could be /dev/stdout, which is the standard Linux "file" that represents stdout.

If this idea doesn't really pan out, alternatively, could a separate "mode" be added to the W3CLogger that just tells it to write to stdout? Perhaps something like this:

builder.Services.AddW3CLogging(logging =>
{
    // proposed:  set the mode to write to stdout
    logging.WriteToStdOut = true;
});

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: DesignThis issue requires design work before implementating.area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions