Closed ErikvdVen closed 9 years ago
@oz123 do you have any idea ?
@ErikvdVen it seems a correct behaviour to me.
logger.warning
is not returning anything. See the code here:
https://hg.python.org/cpython/file/2.7/Lib/logging/__init__.py
What happens when you remove that print statement?
Do you see the warning 'test' in your collection?
As for the failed authentication. Does the code work on a collection or database without authentication with 2.6.3? Mongodb has done some changes regarding authentication, so I am not sure what the exactly is going on without further information.
Thank you for your responses!
I just figured out this morning another database, called "logs", was created and was filled with log records. They where created yesterday around 15:00, so then I had a configuration that worked.
After some trial and error I figured out this configuration worked!
def setup_logging_to_mongo(name):
logger = logging.getLogger(name)
logger.addHandler(MongoHandler(level='DEBUG'))
logger.exception('test')
logger.warning('test')
did not work, but after changing it to logger.exception('test')
it did appear inside the mongodb database. So it seems like it still works, now I only need to figure out how to get it work on mongolab. But I guess that shouldn't be a problem :)
@ErikvdVen how familiar are you with logging levels? The documentation is quite tricky. Make sure you understand what gets logged when. @char0n This ticket can be closed. Can you add me to the list of people who can close tickets please?
Well I guess I have to read the documentation again then :) I just use it a few weeks, for Python, and I only used the exception function so far to log errors. Mostly errors from the postgreSQL pipelines.
But it seems that the logger.warning() doesn't write anything to the mongodb collection and logger.exception() does. I just tried my first configuration on mongolab, only replaced logger.warning() with logger.exception() and it worked.
logger.warning isn't writing anything because you didn't set the application logging level correctly. If you want logging.warning levels to appear you should set the level properly. Look at the test cases for examples.
Aha, that makes sense. I'll look at the test cases. Thanks for your help.
Can we close this issue ?
Yes you can close this issue
Fine, thanks.
When using pymongo 2.6.3 according to the requirements.txt, I receive this error:
Unable to connect to the database. command SON([('authenticate', 1), ('user', u'ads'), ('nonce', u'8607e5da456556b5'), ('key', u'd13b8199999884353743a93e7d739')]) failed: auth failed
But as soon as I upgrade to 3.0.3. the error disappears, but below code returns a None:
Can you help?