Discourse logboekopties

AI-generated summary

In a discussion titled ‘Discourse logging options’ under the Support category, sbernhard asked whether it’s possible to prevent Discourse from logging user-submitted messages, specifically those appearing in production.log (e.g., POST requests with raw content). HAWK requested clarification, and sbernhard confirmed the desire to exclude such messages from logs entirely. HAWK followed up asking what exactly should be changed, and sbernhard reiterated the goal: to avoid seeing user messages in the logs. neounix provided a solution using Rails’ filter_parameters or filter_attributes to exclude sensitive or unwanted parameters like :raw from being logged, referencing Rails 6 documentation and external guides for further detail. This approach allows administrators to selectively suppress logging of specific request parameters without disabling logging entirely.

Are there somewhere configuration options for logging?

I want to prevent discourse to log messages which are currently written by users. Is this somehow possible?

Hi there, can you try to explain again? It’s not clear what you’re asking for here, sorry!

Well, in discourse/rails/production.log every message is logged, like

Started POST "/posts" for 1.15.7.3 at 2020-11-12 13:46:27 +0000
Processing by PostsController#create as */*
  Parameters: {"raw"=>"This is a message which shouldn't be logged in my eyes"

And what are you wanting to change?

I don’t want to see these messages in the log, if possible.

To filter a specific parameter in Rails, you can do this (old method before “filter_attributes”, see below) via a plugin:

Rails.application.config.filter_parameters += [
  :raw,
  :signature,
  :return_url,
  :api_url,
  :access_token_url,
  :code
]

You can also use:

 filter_attributes

See also filter_attributes and other good info on this here:

Hope this helps @sbernhard

See also: