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

Hide certain log messages that pass through custom layout function #1055

Open
mihaibrana opened this issue Dec 8, 2020 · 2 comments
Open

Comments

@mihaibrana
Copy link

mihaibrana commented Dec 8, 2020

Hello :). Thank you for porting & creating this library. Excellent work, that has helped me a great deal :).

I'm using my own layout for an appender.

https://github.com/log4js-node/log4js-node/blob/master/docs/layouts.md

I'd like to filter-out certain LogEvents based on the content (the log message itself), something that is not possible with typical filtering (which is usually limited at levels & categories).

Unfortunately, when I return "", I still get an empty line in the console (which makes sense, since log4js prints whatever the log function returns. But I'm wondering if there's a way to tell log4js to hide a message completely.

Ideally, either when I return "null" or empty string, I would like it to not display anything. Most likely "null" would be a better candidate for this.

I've taken a (short!) look in:

https://github.com/log4js-node/log4js-node/blob/master/lib/layouts.js

But can't figure out exactly where custom layouts are implemented.

@mihaibrana mihaibrana changed the title How to make the custom log4js layout function to hide certain log messages? Hide certain log messages that pass through custom layout function Dec 8, 2020
@quocvu
Copy link

quocvu commented Mar 17, 2022

I would also be interested in knowing this. I'd like to filter based on user-agent. While debugging on production, the log entries from the crawlers are interfering.

@lamweili
Copy link
Contributor

@quocvu I have replied to your user-agent filtering in #1214.

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

3 participants