Skip to content

Limit length of log entries#4028

Merged
svenseeberg merged 1 commit into
developfrom
feat/limit-log-length
Dec 1, 2025
Merged

Limit length of log entries#4028
svenseeberg merged 1 commit into
developfrom
feat/limit-log-length

Conversation

@svenseeberg
Copy link
Copy Markdown
Member

@svenseeberg svenseeberg commented Nov 20, 2025

Short description

We sometimes have log entries with multiple megabytes of base64 encoded images. This breaks reading logs.

Proposed changes

Limit log messages to 4096 characters.

Side effects

  • may cut messages.

Faithfulness to issue description and design

There are no intended deviations from the issue and design.

How to test

Resolved issues


Pull Request Review Guidelines

@svenseeberg svenseeberg force-pushed the feat/limit-log-length branch 2 times, most recently from c714c6f to af7ce56 Compare November 20, 2025 14:57
@svenseeberg
Copy link
Copy Markdown
Member Author

The failed test (generate unique slug) is unrelated to the PR.

@svenseeberg
Copy link
Copy Markdown
Member Author

svenseeberg commented Nov 20, 2025

I already patched this onto the prod server to have a workaround for the long log messages.

@PeterNerlich
Copy link
Copy Markdown
Contributor

I'm not sure how I feel about adding this blanket solution here. I opened up a PR on linkcheck instead, this targets specifically the problematic log message, and specifically data URLs: DjangoAdminHackers/django-linkcheck#219

I'm not sure what to expect regarding when it will be merged and land in a release however

@svenseeberg
Copy link
Copy Markdown
Member Author

svenseeberg commented Nov 24, 2025

We can increase the length to 10k chars or whatever. But truncating too long log entries is something that many programs do to prevent problems.

Copy link
Copy Markdown
Contributor

@PeterNerlich PeterNerlich left a comment

Choose a reason for hiding this comment

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

Sounds good. I'm not sure about whether there is a better way than to just modify the RequestFormatter, but I have no good idea about how logging / django logging is supposed to work and at first glance it doesn't look like there is an easy way to chain formatters or something like that.

One note, if I remember correctly the 4096 will denote proper characters, not bytes, so the storage will still differ by line if some contain UTF characters. I don't think this is a problem though since our goal is to just keep the log file size from exploding

Comment thread integreat_cms/core/logging_formatter.py Outdated
@svenseeberg svenseeberg force-pushed the feat/limit-log-length branch from 32e1b20 to 3be4564 Compare November 26, 2025 13:09
Co-authored-by: Peter Nerlich <PeterNerlich@users.noreply.github.com>
@svenseeberg svenseeberg force-pushed the feat/limit-log-length branch from 3be4564 to 64e919f Compare November 26, 2025 13:31
@svenseeberg svenseeberg merged commit 99c8a7b into develop Dec 1, 2025
5 checks passed
@svenseeberg svenseeberg deleted the feat/limit-log-length branch December 1, 2025 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants