I just install latest version of log4mongo which automatically installed pymongo as dependency. I got below error when instantiating MongoHandler :
TypeError: 'Collection' object is not callable. If you meant to call the 'authenticate' method on a 'Database' object it is failing because no such method exists.
if self.username is not None and self.password is not None: auth_db = self.connection[self.authentication_database_name] self.authenticated = auth_db.authenticate(self.username, self.password)
I resolved it by specifying Mongo URI as host parameter :
db_handler = MongoHandler(host=os.environ[EnvVars.MONGO_URI], database_name=mongo_connection_params['db'], collection='logs')
I just install latest version of log4mongo which automatically installed pymongo as dependency. I got below error when instantiating MongoHandler :
TypeError: 'Collection' object is not callable. If you meant to call the 'authenticate' method on a 'Database' object it is failing because no such method exists.
Here is my code :
db_handler = MongoHandler(host=mongo_connection_params['host'], port=mongo_connection_params['port'], username=mongo_connection_params['username'], password=mongo_connection_params["password"], database_name=mongo_connection_params['db'], collection='logs')
It happens here actually :
if self.username is not None and self.password is not None: auth_db = self.connection[self.authentication_database_name] self.authenticated = auth_db.authenticate(self.username, self.password)
Looks like authenticate method has been removed in the later version of pymongo but log4mongo is still using it. This link also might help : https://debugah.com/solved-typeerror-collection-object-is-not-callable-if-you-meant-to-call-the-authenticate-method-on-a-database-object-it-is-failing-because-no-such-method-exists-23011/