Skip to content

feat: configurable logging (stdout/file/syslog, text/JSON, per-package levels)#41

Merged
jensens merged 8 commits into
mainfrom
feat/configurable-logging
Mar 24, 2026
Merged

feat: configurable logging (stdout/file/syslog, text/JSON, per-package levels)#41
jensens merged 8 commits into
mainfrom
feat/configurable-logging

Conversation

@jensens
Copy link
Copy Markdown
Member

@jensens jensens commented Mar 24, 2026

Summary

Closes #40.

  • Make logging fully configurable via instance.yaml — handlers (stdout/file/syslog), format (text/JSON/custom), per-package log levels, access log toggle.
  • Default is now stdout to stderr in text format (12-factor pattern). File logging is opt-in via log_file: true.
  • JSON format requires python-json-logger as a runtime dependency.
  • location_log is deprecated in favor of log_file_path.

New variables

Variable Default Purpose
log_format text text, json, or custom via log_format_class
log_level INFO Root logger level
log_stdout / log_stdout_stream true / stderr stdout/stderr handler
log_file / log_file_path false / "" File handler
log_syslog + _host, _port, _facility, _protocol false Syslog handler
access_log_enabled true Toggle translogger pipeline + wsgi logger
logging_loggers {"plone": "INFO", ...} Per-package log levels dict

Breaking changes

  • File logging is now off by default. Deployers who relied on file logging need to add log_file: true.
  • When access_log_enabled is true, access log entries now also appear on stdout/syslog (previously file-only).

Test plan

  • 27 new tests covering validation, formatters, handlers, loggers, and 3 integration scenarios (cloud-native, traditional, hybrid)
  • All 64 tests pass (37 existing + 27 new)
  • Manual smoke test with a real Plone instance
  • Verify JSON output parses correctly with a log aggregator

🤖 Generated with Claude Code

jensens added 7 commits March 24, 2026 14:03
Validates log_format, log handler enablement, log_stdout_stream,
log_syslog_protocol, and log_syslog_facility in pre_gen_project.py,
with corresponding tests in tests/test_bake_logging.py.
Replaces the hardcoded logging configuration with a fully conditional
Jinja2 template driven by new cookiecutter.json variables: log_format,
log_level, log_stdout, log_file, log_syslog, access_log_enabled, and
logging_loggers. Supports text, JSON, and custom formatter classes;
console (stdout/stderr), file, and syslog handlers; and configurable
per-logger log levels.
Conditional generation of handlers (console, file, syslog), formatters
(text, json, custom), loggers (dict-based), and access log pipeline.
All driven by new log_* cookiecutter variables.
Add 22 template output tests to test_bake_logging.py covering formatters,
handlers, loggers, and integration scenarios. Update test_bake_with_defaults
to verify default logging configuration (stderr console handler, generic
text formatter, wsgi logger, and translogger middleware).
Add how-to guide and reference page for configurable logging (Task 10).
Mark location_log as deprecated in basic-config reference.
Add 2.5.0 unreleased changelog entry.
@jensens jensens requested a review from gogobd March 24, 2026 14:04
@jensens jensens added the enhancement New feature or request label Mar 24, 2026
Copy link
Copy Markdown
Contributor

@gogobd gogobd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, tests were running locally. I tried out our current copy of the production site and everything worked as expected.

@jensens jensens merged commit eed8fd7 into main Mar 24, 2026
5 checks passed
@jensens jensens deleted the feat/configurable-logging branch March 24, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable logging to stdout and / or an external log server

2 participants