---
name: "mongoc_structured_log_opts_set_max_levels_from_env"
section: "3"
platform: "linux"
package: "libmongoc-doc"
version: "1.30.4-1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mongoc_structured_log_opts_set_max_levels_from_env"
---

# mongoc\_structured\_log\_opts\_set\_max\_levels\_from\_env(3)

## SYNOPSIS

```
bool
mongoc_structured_log_opts_set_max_levels_from_env (mongoc_structured_log_opts_t *opts);
```

Sets any maximum log levels requested by environment variables: **MONGODB\_LOG\_ALL** for all components, followed by per-component log levels **MONGODB\_LOG\_COMMAND**, **MONGODB\_LOG\_CONNECTION**, **MONGODB\_LOG\_TOPOLOGY**, and **MONGODB\_LOG\_SERVER\_SELECTION**.

Expects the value to be recognizable by *mongoc\_structured\_log\_get\_named\_level()*. Parse errors may cause a warning message, delivered via unstructured logging.

Component levels with no valid environment variable setting will be left unmodified.

This happens automatically when *mongoc\_structured\_log\_opts\_new()* establishes defaults. Any subsequent programmatic modifications to the *mongoc\_structured\_log\_opts\_t* will override the environment variable settings. For applications that desire the opposite behavior, where environment variables may override programmatic settings, they may call **mongoc\_structured\_log\_opts\_set\_max\_levels\_from\_env()** after calling *mongoc\_structured\_log\_opts\_set\_max\_level\_for\_component()* and *mongoc\_structured\_log\_opts\_set\_max\_level\_for\_all\_components()*. This will process the environment a second time, allowing it to override customized defaults.

## RETURNS

Returns **true** on success. If warnings are encountered in the environment, returns **false** and may log additional information to the unstructured logging facility. Note that, by design, these errors are by default non-fatal. When *mongoc\_structured\_log\_opts\_new()* internally calls this function, it ignores the return value.

**SEE ALSO:**

```
Structured Logging
```

## AUTHOR

MongoDB, Inc

## COPYRIGHT

2009-present, MongoDB, Inc.
