Open nabeenb opened 11 months ago
Please share more code, this is impossible to help you like this.
try: mongo = BufferedMongoHandler(host=uri,
#password='',
database_name='chatlogs',
collection='logs',
authentication_db='chatlogs',
capped=True,
buffer_size=1000, # buffer size.
buffer_periodical_flush_timing=60.0, # periodical flush every 60 seconds
buffer_early_flush_level=logging.CRITICAL)
log = logging.getLogger(name) log.addHandler(mongo) except Exception as e: logger.error (f"Could not connect to mongodb server: {traceback.format_exc()}", e.traceback ) raise CustomAPIException(e._message, e.code)
just to add my requirement is to log the connection error to a separate file instead standard output
I am unable to log into a log file for any connection error, while it prints to stdout
--- Logging error --- Traceback (most recent call last): lib/python3.11/site-packages/log4mongo/handlers.py", line 295, in flush_to_mongo getattr(self.collection, write_many_method)(self.buffer)
Please let me know if anyone has already solved this.