Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-26625

Config option for all non-error logs to be written to STDOUT

    XMLWordPrintable

Details

    • Task
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      The scenario

      When run in a container, the MariaDB error log defaults to STDERR, which can be easily read and processed by an external service.

      Other logs such as the audit log, can write to a file or syslog, but syslog requires an extra service container.

      Tailing a log file requires an extra container, or a sidecar container, to be run per-instance of MariaDB just to tail and forward the log data.

      If the remaining logs could all write to STDOUT, we would no longer have to worry about log storage and rotation on a container and matching volume, while exporting all log streaming and processing into a separate, often centralised, service.

      Manually Re-directing to STDOUT/STDERR
      The simplest solution is to set the log file paths up as symlinks to /dev/stdout, or even the host processes relevant file descriptor in /proc/self/fd/1.
      But because the MariaDB container runs as a non-root user, MariaDB doesn't have permission to write to a symlink created by root.

      2021-09-16 12:47:47 0 [ERROR] mysqld: File '/tmp/out.log' not found (Errcode: 13 "Permission denied")
      2021-09-16 12:47:47 0 [ERROR] Could not use /tmp/out.log for logging (error 13). Turning logging off for the whole duration of the MariaDB server process. To turn it on again: fix the cause, shutdown the MariaDB server and restart it.
      

      In a Dockerfile spec, you can switch to the mysql user, and create the symlink, in your MariaDB config, and point any log file to /tmp/out.log:

      FROM mariadb:latest
      ADD my.cnf /etc/my.cnf
      USER mysql
      RUN ln -sf /dev/stdout /tmp/out.log
      

      This might break behaviour in other areas, as you would then need to specify to connect to a container as root:

      docker exec -it db1 --user root bash
      

      Solution
      Allow other logs (audit, sql error, slow, general, more?) to be written to stdout.
      Maybe when not specifying a path, similar to how log_error is configured.

      Attachments

        Activity

          People

            Unassigned Unassigned
            richard.bensley Richard Bensley (Inactive)
            Votes:
            5 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.