log4mongo / log4mongo-python

python logging handler for mongo database
http://log4mongo.org
Other
111 stars 37 forks source link

how to log to file and as well to mongodb #56

Closed nabeenb closed 9 months ago

nabeenb commented 9 months ago

I have a situation to log to file and same time to write to mongodb log with different logging.basicConfig level of Info and Error. Any idea how can achieve this? If I set basic config to Error I can't log as Info to file.

oz123 commented 9 months ago

You need to define two handlers.

One for the mongo and one for the find. Basic config is... Well... Basic...

logger = logging.getLogger().addHandler(mongohandler)
logger.addHandler(filehandler)