Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /
SDK de C++

Logging - C++ SDK

You can set or change your app's log level to develop or debug your application. You might want to change the log level to log different amounts of data depending on the app's environment.

Tip

For information on how to set the Sync client log level, refer to Set the Sync Client Log Level - C++ SDK.

Puede configurar el nivel de detalle informado por el SDK de Realm C++. Pase un realm::logger::level al set_default_level_threshold() función miembro:

auto logLevel = realm::logger::level::info;
realm::set_default_level_threshold(logLevel);

To set a custom logger function, create a realm::logger and override the virtual do_log() member function:

struct MyCustomLogger : realm::logger {
// This could be called from any thread, so may not output visibly to the
// console. Handle output in a queue or other cross-thread context if needed.
void do_log(realm::logger::level level, const std::string &msg) override {
std::cout << "Realm log entry: " << msg << std::endl;
}
};

Then, initialize an instance of the logger and set it as the default logger for your realm:

auto config = realm::db_config();
auto thisRealm = realm::db(config);
auto myLogger = std::make_shared<MyCustomLogger>();
realm::set_default_logger(myLogger);

Volver

Stream Data to Atlas

En esta página