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

Different logging levels for appenders in same logger #20

Open
ShehabElsayed opened this issue Nov 22, 2021 · 1 comment
Open

Different logging levels for appenders in same logger #20

ShehabElsayed opened this issue Nov 22, 2021 · 1 comment

Comments

@ShehabElsayed
Copy link

Hi,

Is there a way to have 2 appenders in the same logger but with different logging levels? For example, can I add a console appender with level INFO and a file appender with level DEBUG to the same logger such that the results would be like the following?

  • info(logger, "Hello"): would write Hello to both console and file
  • debug(logger, "Hello"): would only write Hello to file

Thank you very much in advance.

@atheriel
Copy link
Collaborator

atheriel commented Dec 2, 2021

I don't think this is possible with the current API, as appenders do not have separate thresholds.

But it's almost certainly possible to accomplish this:

  1. Write a custom console appender that handles the level internally and drops DEBUG messages.
  2. Set the logger's overall threshold at DEBUG and use the existing file appender.

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

No branches or pull requests

2 participants