-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
DispatcherMiddleware with different loggers per app in flask 1.0 #2866
Comments
It logs twice because you're adding two handlers to the same logger. Add one handler to the To get different names, override class LoggerFlask(Flask):
@property
def logger(self):
return super().logger.getChild(self.name)
app1 = LoggerFlask("app1")
app2 = LoggerFlask("app2") Or see the docs on logging for how to inject extra information into log records. In your case you would inject |
Thanks for the workaround. I can see this is not really a bug per se - just a breaking change for my setup :), but while I can see from PR 2436 that |
Since we now use the Multiple apps was an unforseen case, and I understand how this can be inconvenient. I'm hesitant to make this configurable again. Perhaps a compromise would be |
Or even just hard code using |
After upgrading to flask 1.0 logging from different apps using DispatcherMiddleware, each log emitted is written to all handlers in the different apps. I assume this caused by
app.logger
always having the nameflask.app
, maybe?Here is a example:
Run with
And then make a request to / and /app2/. Each error log will be written in both logfiles.
Environment
My actual app is using
current_app.logger
with blueprints with the same behaviour, but I assume it the same issue.The text was updated successfully, but these errors were encountered: