Registry / observability / oslo-log

oslo-log

JSON →
library8.3.1pypypi✓ verified 27d ago

oslo.log is a Python library that provides standardized logging configuration for OpenStack projects. It offers custom formatters, handlers, and support for context-specific logging, enhancing the standard Python logging module. The current version is 8.1.0 and it's actively maintained by the OpenStack community with regular releases.

pip install oslo.log
INSTALL
IMPORT
SIG · OSLO-LOG
O
oslo-log
observabilitypythonv8.3.1
Install
4.8s avg
Import
545ms
Disk
48MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v8.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.560s · 44.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 4.8s · import 0.530s · 47MB
48MB installed
● package 48MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

log
✓ from oslo_log import log
cfg
✓ from oslo_config import cfg
oslo.log relies on oslo.config for its configuration management.

This quickstart demonstrates the basic setup and usage of oslo.log. It involves importing `cfg` from `oslo_config` to manage configuration options, registering `oslo.log`'s options, and then initializing the logging system with `logging.setup()`. Finally, it shows how to obtain a logger and emit messages at different levels.

import os from oslo_config import cfg from oslo_log import log as logging # Define a configuration group and options (typically done in a separate config file) CONF = cfg.CONF CONF.register_group(cfg.OptGroup('DEFAULT')) # Register oslo.log options (required for oslo.log to pick up config) logging.register_options(CONF) # Set up logging for your application # The 'product_name' is usually your application's name # The 'version' is your application's version DOMAIN = os.environ.get('OSLO_LOG_DOMAIN', 'my_app') # Example for context logging.setup(CONF, DOMAIN, version='1.0.0') # Get a logger instance LOG = logging.getLogger(__name__) # Log messages LOG.info("This is an informational message.") LOG.warning("This is a warning message.") LOG.error("This is an error message.") # Example of setting a default log level (if not using a config file) # This would typically be done via a config file or oslo.config options # For demonstration, setting it programmatically (ensure it's before logging.setup if permanent) # logging.set_defaults(default_log_levels=['my_app=DEBUG'])
Debug
Known issues
gotchaWhen `log_config_append` is specified, all other logging configuration options (e.g., `log_date_format`, `log_file`, `use_syslog`, `default_log_levels`) are ignored. Logging is fully controlled by the specified configuration file.
fix
If you intend to use a logging configuration file, define all logging settings within that file. If you prefer `oslo.log`'s programmatic or `oslo.config` options, do not set `log_config_append`.
affects: All versions
gotchaChanging log format strings can be tricky, especially distinguishing between `logging_context_format_string` and `logging_default_format_string`. `log.set_defaults()` only affects the context-based format string.
fix
To modify the `logging_default_format_string` (for logs without context), use `CONF.set_override('logging_default_format_string', 'YOUR_FORMAT_STRING')` or define it in your `oslo.config` configuration file under the `[DEFAULT]` section. The `logging_context_format_string` is used when an `oslo.context` object is attached to the log message.
affects: All versions
deprecatedThe existing syslog format used by `oslo.log` is deprecated and will be changed to honor RFC5424 in future versions.
fix
Be aware that applications relying on the exact syslog message format may need adjustments in the future. Monitor `oslo.log` release notes for details on when the RFC5424 change is implemented. This option is ignored if `log_config_append` is set.
affects: Versions 7.0.0 and later
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'oslo_log'
The 'oslo.log' library is not installed in your Python environment or is not accessible within the current `PYTHONPATH`.
fix
Install the library using pip: `pip install oslo.log`.
AttributeError: 'module' object has no attribute 'getLogger'
This typically occurs when a local Python file is inadvertently named `logging.py`, shadowing the standard Python `logging` module and causing incorrect imports.
fix
Rename your Python script or any conflicting local file that might be named `logging.py` to avoid collision with the standard library.
logging.basicConfig() has no effect (oslo.log is not configured as expected)
`oslo.log` takes control of the logging configuration. If `logging.basicConfig()` is called after `oslo.log`'s `setup()` function has initialized, or if other handlers are already present on the root logger, `basicConfig()` will have no effect.
fix
Configure logging using `oslo_log.setup()` with an `oslo_config.cfg.ConfigOpts` object, or ensure `logging.basicConfig()` is called before `oslo_log` or any other library configures the root logger.
Cannot change oslo_log log format (e.g., 'logging_default_format_string' not applied)
`oslo.log` distinguishes between log messages with an `oslo.context` attached (`logging_context_format_string`) and standard messages (`logging_default_format_string`). Changes made via `log.set_defaults()` primarily affect context-aware formats, leaving regular log lines unchanged.
fix
To modify the format for regular log lines, use `CONF.set_override('logging_default_format_string', 'YOUR_FORMAT_STRING')` before calling `oslo_log.setup()`, or specify it directly in your configuration file.
Upgrade
Version history
8.3.1latest on PyPI · released Aug 27, 2026
Audit
Dependencies
oslo.configrequiredUsed for defining and managing configuration options for logging.
oslo.contextoptionalProvides helpers to maintain request context information, which oslo.log uses for context-specific logging.
Agent activity
20 hits · last 30 days
node
14
Amazon
3
OpenAI (training)
2
Resources
oslo-log — pip install oslo-log · libregistry