-
Notifications
You must be signed in to change notification settings - Fork 185
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
Logging Issues #11
Comments
First of all, it only happens with Python 2.7, in Python 3.4 it works fine because the logging library has different behaviour between those versions. Flask uses a logger called werkzeug with one handler StreamHandler attached into it that writes everything into the console. If you want you can check this out here: https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/_internal.py#L80 APScheduler uses another logger called apscheduler.executors, by default this logger doesn't have any handler attached for this reason you see this message No handlers could be found for logger. Why does it work when calling basicConfig()? If you add manually a StreamHandler to the Root Logger it will works too. logger = logging.getLogger() # this returns the root logger
logger.addHandler(logging.StreamHandler()) Usually I fix it just calling basicConfig() in the app startup Any question let me know. Cheers! |
Thanks, I switched to Python 3 and fixed the problem. I haven't got it working with python 2.7. I'll look into it when I have the time and post the code. Thanks again. |
Ok, I will close it for now. |
Essentially a continuation of issue #1, opening a separate issue as the old one is closed, get the message
No handlers could be found for logger "apscheduler.executors.default"
. This happens when a error is present in the scheduler code. (The function that is called by the scheduler).To test, please run this. It's modified off the one in the examples folder to throw an error.
https://gist.github.com/HackToHell/b8c73a2c6db53e9881ac
Output
It seems to be an issue with APScheduler library itself, https://bitbucket.org/agronholm/apscheduler/issues/78/no-handlers-could-be-found-for-logger. So the suggested method to catch the errors is to have a basic logging setup ( http://stackoverflow.com/q/28724459/787563 ). I tried that and added it to the code. This resulted in flasks logging system's output being killed off.
I added
after the imports.
New Output - Shows the proper output. (Notice there's no message from flask present in the previous run)
This comment in the same SO thread says the very same to author of the library, however he says that it should not be the case. Unfortunately I am unable to debug the issue further due to my lack of experience with python's logging system(It's pretty weird).
Is there any way to resolve the issue by ideally having the output from flask and APScheduler in the same place ?
The text was updated successfully, but these errors were encountered: