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

Change LogLevel in runtime for single request #88599

Open
1 task done
niuzheng168 opened this issue Jul 5, 2023 · 4 comments
Open
1 task done

Change LogLevel in runtime for single request #88599

niuzheng168 opened this issue Jul 5, 2023 · 4 comments

Comments

@niuzheng168
Copy link

niuzheng168 commented Jul 5, 2023

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'd like to change log level in runtime for a single request.
My scenario is when customer report a bug that can only repro in PROD, they can send a request with additional parameter debug=1 like https://mywebservice.com/request?para1=value1&debug=1

And in runtime, I will create a logger with LogLevel = Debug, and very thing will be logged.

Change the log level in environment variable or appsettings.json will impact other queries, but we are not allowed to touch any customer data.

Describe the solution you'd like

I'd like to have an overload method with additional parameter in ILoggerFactory.CreateLogger(LogLevel loglevel)

Additional context

No response

@gfoidl
Copy link
Member

gfoidl commented Jul 5, 2023

Why not log a separate entry (i.e. with level Info or Warning) when debug=1 is set?
I.e. don't use the default request logging for this, rather use custom logging.

@Tratcher
Copy link
Member

Tratcher commented Jul 5, 2023

Related:
dotnet/aspnetcore#39200
#82465

@niuzheng168
Copy link
Author

Why not log a separate entry (i.e. with level Info or Warning) when debug=1 is set? I.e. don't use the default request logging for this, rather use custom logging.

This sounds a just workaround. I'd like reuse same logger but just a log level change.

@davidfowl davidfowl transferred this issue from dotnet/aspnetcore Jul 10, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jul 10, 2023
@ghost
Copy link

ghost commented Jul 10, 2023

Tagging subscribers to this area: @dotnet/area-extensions-logging
See info in area-owners.md if you want to be subscribed.

Issue Details

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'd like to change log level in runtime for a single request.
My scenario is when customer report a bug that can only repro in PROD, they can send a request with additional parameter debug=1 like https://mywebservice.com/request?para1=value1&debug=1

And in runtime, I will create a logger with LogLevel = Debug, and very thing will be logged.

Change the log level in environment variable or appsettings.json will impact other queries, but we are not allowed to touch any customer data.

Describe the solution you'd like

I'd like to have an overload method with additional parameter in ILoggerFactory.CreateLogger(LogLevel loglevel)

Additional context

No response

Author: niuzheng168
Assignees: -
Labels:

area-Extensions-Logging

Milestone: -

@tarekgh tarekgh added this to the Future milestone Jul 10, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants