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

Feature Request: Assigned different appenders to a category with different log levels #1416

Open
stanleyxu2005 opened this issue Jan 21, 2024 · 1 comment

Comments

@stanleyxu2005
Copy link

stanleyxu2005 commented Jan 21, 2024

Hi Project Maintainer.

How I implement now

Before using log4js, I use console to log everything. By using log4js, I want to print everything into out.log and in addition, print all errors into err.log.

After reading the document, I should do it as follows:

  1. Define 3 appenders: out with type: 'stdout', err with type: 'stderr' and logErrOnly with type: 'logLevelFilter', logLevel: 'error'
  2. Define a default category with 2 appenders out and logErrOnly.

That's what I found in the FAQ section (also see docs/logLevelFilter.md)

How I propose to implement

I'd like to know, if it is considered to be put into roadmap, to configure it is a straightfoward way like this

{
   appenders: {
       out: { type: 'stdout' },
       err: { type: 'stderr' },
   },
   categories: {
      default: { 
         appenders: [
            { name: 'out', logLevel: 'all' },
            { name: 'err', logLevel: 'error' }
        ]
      }
   }
}
@lamweili
Copy link
Contributor

Pull requests are welcomed!

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