-
-
Notifications
You must be signed in to change notification settings - Fork 751
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
Don't include log messages with log level "AUDIT" in regular service log file #4538
Conversation
messages with log level "AUDIT" if log level is set to INFO or higher. This way we avoid issues with duplicate AUDIT messages in production deployments. In production deployments default log level is set to INFO which means that all service log files will also contain AUDIT log messages because AUDIT level if the highest. This is not desired, because we already log AUDIT log messages in a dedicated AUDIT log file. NOTE: Audit messages will still go in the service log file is log level is set to DEBUG (that's desired during debugging).
b5ed972
to
09feb5d
Compare
based filtering works correctly.
Added integration tests in 11111ff. |
Randomly found out just now while debugging some other things that this doesn't work correctly on production gunicorn deployments. I believe issue is related to another change, I'm digging in. |
Not doing that means change / fix in #4538 won't work since regular config which includes DEBUG and AUDIT will be used over gunicorn one.
^Second time is the charm - #4621. The code was correct, but we were using incorrect logging config for API services with packages so those log messages weren't filtered out by default. |
This pull request resolves an issue with log messages with log level AUDIT ending up in regular service log file (
<service>.log
) in addition to the service audit log file (<service>.audit.log
).Background
We implemented
AUDIT
log level by adding a new log level constant which contains the highest log level number (CRITICAL
+ 10).Default Python log level filtering works using "include log messages with log level and above" approach. This means messages with
AUDIT
log level will always be included in the logs becauseAUDIT
is the highest level.In most cases that's not desired. That's especially true for production deployment where default log level is
INFO
and we have dedicated log file with audit log messages. We don't want audit log messages to also end up in the regular service log file where they just cause noise.Implementation wise, I needed to implement it using a log filter - we exclude log messages with level
AUDIT
if log level is set toINFO
or higher, but not toAUDIT
. I couldn't make a simpler change like settingAUDIT
log level constant to lower thanINFO
, because then we would have the opposite problem (nonAUDIT
messages would also end up in the audit log file).NOTE: To aid with the debugging,
AUDIT
log messages are also included in a regular service log file if log level is set toDEBUG
of ifsystem.debug
config option is set toTrue
. When debug is enabled there are many more log messages coming from other places soAUDIT
should be the least of your concerns :)Resolves #4502 (thanks to @nmaludy for reporting it).
TODO