{"id":5001,"library":"oslo-log","title":"Oslo Logging Library","description":"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.","status":"active","version":"8.1.0","language":"en","source_language":"en","source_url":"https://github.com/openstack/oslo.log","tags":["logging","openstack","configuration","log management","structured logging"],"install":[{"cmd":"pip install oslo.log","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for defining and managing configuration options for logging.","package":"oslo.config","optional":false},{"reason":"Provides helpers to maintain request context information, which oslo.log uses for context-specific logging.","package":"oslo.context","optional":true}],"imports":[{"symbol":"log","correct":"from oslo_log import log"},{"note":"oslo.log relies on oslo.config for its configuration management.","symbol":"cfg","correct":"from oslo_config import cfg"}],"quickstart":{"code":"import os\nfrom oslo_config import cfg\nfrom oslo_log import log as logging\n\n# Define a configuration group and options (typically done in a separate config file)\nCONF = cfg.CONF\nCONF.register_group(cfg.OptGroup('DEFAULT'))\n\n# Register oslo.log options (required for oslo.log to pick up config)\nlogging.register_options(CONF)\n\n# Set up logging for your application\n# The 'product_name' is usually your application's name\n# The 'version' is your application's version\nDOMAIN = os.environ.get('OSLO_LOG_DOMAIN', 'my_app') # Example for context\nlogging.setup(CONF, DOMAIN, version='1.0.0')\n\n# Get a logger instance\nLOG = logging.getLogger(__name__)\n\n# Log messages\nLOG.info(\"This is an informational message.\")\nLOG.warning(\"This is a warning message.\")\nLOG.error(\"This is an error message.\")\n\n# Example of setting a default log level (if not using a config file)\n# This would typically be done via a config file or oslo.config options\n# For demonstration, setting it programmatically (ensure it's before logging.setup if permanent)\n# logging.set_defaults(default_log_levels=['my_app=DEBUG'])\n","lang":"python","description":"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."},"warnings":[{"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`.","message":"When `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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Changing 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.","severity":"gotcha","affected_versions":"All 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.","message":"The existing syslog format used by `oslo.log` is deprecated and will be changed to honor RFC5424 in future versions.","severity":"deprecated","affected_versions":"Versions 7.0.0 and later"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}