Open
Description
Issue :
File "/usr/local/lib/python2.7/dist-packages/log4mongo/handlers.py", line 123, in __init__
self._connect(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/log4mongo/handlers.py", line 145, in _connect
self.connection.is_locked
File "/home/sreenadh/.local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 1186, in is_locked
ops = self._database_default_options('admin').current_op()
File "/home/sreenadh/.local/lib/python2.7/site-packages/pymongo/database.py", line 620, in current_op
return sock_info.command("admin", cmd)
File "/home/sreenadh/.local/lib/python2.7/site-packages/pymongo/pool.py", line 239, in command
read_concern)
File "/home/sreenadh/.local/lib/python2.7/site-packages/pymongo/network.py", line 102, in command
helpers._check_command_response(response_doc, None, allowable_errors)
File "/home/sreenadh/.local/lib/python2.7/site-packages/pymongo/helpers.py", line 205, in _check_command_response
raise OperationFailure(msg % errmsg, code, response)
OperationFailure: not authorized on admin to execute command { currentOp: 1, $all: false }
What am trying to do with log4mongo :
I am writing a scrapy spider in which I need the log to be sent to MongoDB. My other mongo connections using MongoClient
auth uri works fine. (ie.: client=MongoClient('mongodb://username:password@localhost:27045')
) with auth db as admin
that has roles granted accordingly.
I followed the README, but I can't get the Auth part to work, when the MongoDB is with auth disabled, the connection works.
handler = MongoHandler(
level=logging.DEBUG,
host='localhost',
port=27045,
database_name='SPIDER_LOGS',
collection='logs',
username='username_here',
password='password_here',
authentication_db='admin'
)
Versions used:
python : 2.7
mongodb : 3.4.4
pymongo : 3.4.0
Metadata
Metadata
Assignees
Labels
No labels