Skip to content

Allow configuring W3CLogging to write to stdout #42489

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

Open
1 task done
ajkonkol opened this issue Jun 29, 2022 · 8 comments
Open
1 task done

Allow configuring W3CLogging to write to stdout #42489

ajkonkol opened this issue Jun 29, 2022 · 8 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions Needs: Design This issue requires design work before implementating.

Comments

@ajkonkol
Copy link

ajkonkol commented Jun 29, 2022

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

@adityamandaleeka
Copy link
Member

Triage: seems like a reasonable ask, but we'd need to figure out the right API design (maybe a StreamWriter that can be configured?). Putting into .NET 8 planning for now.

@jonathanbyrne
Copy link

This would be very helpful!!!

@adityamandaleeka adityamandaleeka added the Needs: Design This issue requires design work before implementating. label Oct 2, 2022
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 25, 2023
@brianpmccullough
Copy link

I would also find value in this.

@adityamandaleeka
Copy link
Member

Unfortunately we weren't able to get to this in .NET 8 and we're locking down for release now. I'm going to move it into the .NET 9 milestone. If anyone would like to propose a design or implementation, please let us know.

@ghost
Copy link

ghost commented Aug 31, 2023

Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@PeterOscarsson
Copy link

I would like to have this feature. Some kind of configurable system, so I can log to file/stdout or write my own logger (to send to centralized log management)

@vhs94
Copy link

vhs94 commented Apr 3, 2024

this one would be awesome! Any work around in the meantime?

@rmannibucau
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions Needs: Design This issue requires design work before implementating.
Projects
None yet
Development

No branches or pull requests

9 participants