Skip to content

Ensure the correct messages are written to the server log

Description

The log_min_messages setting specifies the message levels that are written to the server log.

Each level includes all the levels that follow it. The later the level, the fewer messages are sent.

Valid values are: - DEBUG5 - DEBUG4 - DEBUG3 - DEBUG2 - DEBUG1 - INFO - NOTICE - WARNING - ERROR - LOG - FATAL - PANIC

WARNING is considered the best practice unless indicated otherwise by your organization's logging policy.

Rationale

If this is not set to the correct value, too many messages or too few messages may be written to the server log.

Applies To

  • Databases

Tags

This rule is applied when the following tags are present:

Tag With Value
secureclouddb/provider aws
secureclouddb/service rds
secureclouddb/engine postgres

Default Rule

const { checkServerSetting } = module

/**
 * @param {Object} databaseSettings - database settings object
 * @returns {boolean} true if the log_min_messages log level is set correctly
 */

function validate(databaseSettings, parameters = { log_min_messages : 'warning' }) {
    const settingName = 'log_min_messages'
    const expectedValue = parameters.log_min_messages
    const success = checkServerSetting(databaseSettings, settingName, expectedValue)
    return {
        success,
    }
}

// invoke
// TODO: add parameters
validate(databaseSettings);