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

💡 [datadogLogs] Customizable levels per logger's handler type #3100

Open
morzel85 opened this issue Oct 28, 2024 · 5 comments
Open

💡 [datadogLogs] Customizable levels per logger's handler type #3100

morzel85 opened this issue Oct 28, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@morzel85
Copy link

It is possible to setup both console and http handler for a logger, but AFAIK it is not possible to configure different levels for the handlers.

I would like to have debug level for console and info for http (more data in browser console, less data on DD servers).

My current workaround is to have the level defined as debug and using beforeSend event to filter out debug level messages from sending to DD servers, it works but more explicit/declarative API would be nice.

@morzel85 morzel85 added the enhancement New feature or request label Oct 28, 2024
@cy-moi
Copy link
Contributor

cy-moi commented Oct 29, 2024

Hi @morzel85 ,

Thank you for reaching out. Are you looking for the configuration forwardConsoleLogs? It provides the ability to forward console logs at different levels.

@morzel85
Copy link
Author

If I were to switch to log forwarding, then all the console calls (of certain level) would be captured, right? The issue here is that some entries to console are inserted by code outside of my control, hence the preference to use DD logger.

@amortemousque
Copy link
Contributor

Hello @morzel85,
One way to have different levels for the handlers could be to create different loggers with the createLogger API. Let me know if that answer your question.

@morzel85
Copy link
Author

morzel85 commented Nov 4, 2024

Using two different loggers would be more complex than the beforeSend filter 'trick' I use now. With single logger, the code that does the logging (creates entries) doesn't need to be aware of any destination config.

@amortemousque
Copy link
Contributor

@morzel85,
I understand that using beforeSend might be more convenient in your case, and I think it’s a good workaround. I’ll let you know when we have an alternative solution for this.

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

No branches or pull requests

3 participants