Logging format breaks structured logs

Created on 16 May 2024, 6 months ago
Updated 8 July 2024, 5 months ago

Problem/Motivation

The log message shouldn't contain html stuff.

$this->logger
        ->info("@endpoint <br/>\n<pre>@data</pre>", [

In my opinion there shouldn't be any HTML here. Other implementations that heavily rely on structured logs would have some problems parsing this messages.

Steps to reproduce

Configure csp to work with this module and monolog to format as json (structured logs)

Proposed resolution

Remove any html from the log message.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Postponed: needs info

Version

2.0

Component

Code

Created by

🇮🇹Italy Bladedu Italy

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Bladedu
  • 🇨🇦Canada gapple

    Can you provide more info on a system / use case for structured log data? From what I saw looking at monolog's JSON formatter, it would result in a stringified JSON (the violation report data) inside a JSON object (the log data's message attribute). Also complicated by the local endpoint name not being part of the violation report data, so the message isn't a clean JSON string even without the HTML.

    The current module roadmap is to change from using the site log to storing reports in a dedicated database table. The storage manager could then be swapped out to send reports in the necessary format to whatever service you're using instead of to the database.
    It's not currently planned to make that a plugin so you could implement a service to proxy violation reports to whichever service you use, but is a future possibility.

  • 🇺🇸United States charginghawk

    FWIW, I don't use this module, but right now I'm debugging an issue where using \

     in logging causes our log manager to break each line out into its own message, introducing a ton of noise and making it very hard to connect the thread between all the entries. This is using Acquia and Sumo Logic.
  • 🇨🇦Canada gapple

    @charginghawk
    sounds like syslog and newlines, rather than specifically pre?
    This issue came up in the CSP module, which logs the same way: Add setting for pretty printing violoation reports in the log Active
    and a related core issue: 📌 Sort out @backtrace_string logging by Syslog module Active
    Not sure if the ini setting can be adjusted on Acquia

  • Status changed to Postponed: needs info 5 months ago
  • 🇺🇸United States charginghawk

    ini_set('syslog.filter', 'raw'); did end up resolving the issue for us.

Production build 0.71.5 2024