[CXX-876] Custom logger ins not working Created: 23/Mar/16  Updated: 26/Mar/16  Resolved: 26/Mar/16

Status: Closed
Project: C++ Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Pavel Odintsov Assignee: Andrew Morrow (Inactive)
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Hello!

I'm trying to enabled detailed mongo client logging with my C++ code.

I've wrote my custom logger:
```bash
class fastnetmon_mongo_logger : public mongocxx::logger {
public:
fastnetmon_mongo_logger()

{ extern log4cpp::Category& logger; logger << log4cpp::Priority::INFO << "Custom mongo library logger intialized"; }

void operator() (mongocxx::log_level level, mongocxx::stdx::string_view domain, mongocxx::stdx::string_view message) noexcept final

{ extern log4cpp::Category& logger; logger << log4cpp::Priority::ERROR << "Log message from Mongodb driver!"; }

};
```

And specified it for mongo instance:
```bash
mongocxx::instance mongo_instance

{ mongocxx::stdx::make_unique<fastnetmon_mongo_logger>() }

;
```

But looks like it's not working because I haven't any log records...

So also I could not find any way to specify log level logging.



 Comments   
Comment by Andrew Morrow (Inactive) [ 26/Mar/16 ]

Closing this as I've not heard back in a while, but feel free to re-open it if you are still having problems.

Comment by Andrew Morrow (Inactive) [ 24/Mar/16 ]

Hi pavel.odintsov - Did the above solutions work out for you? Is there anything more we can help you with in this ticket? Otherwise I would like to close it out.

Comment by Andrew Morrow (Inactive) [ 23/Mar/16 ]

Have a look at this test for a good example:

https://evergreen.mongodb.com/version/mongodb_cpp_driver_dev_14abf61eedd3e7145b8ba1cc01051c6831905105

Comment by Andrew Morrow (Inactive) [ 23/Mar/16 ]

Perhaps it is working, but the driver hasn't felt the need to log anything. After setting up your custom logger, you could try calling the C driver mongoc_log function directly to force it to log and see if your logger is called.

As far as level, we call you back with the level, you decide whether to log at that level or not. There doesn't seem to be a way to tell the C driver to filter internally.

Generated at Wed Feb 07 22:00:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.