<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="error-log-syslog">
      </a>
      7.4.2.8 Error Logging to the System Log
     </h4>
    </div>
   </div>
  </div>
  <p>
   It is possible to have
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   write the error
        log to the system log (the Event Log on Windows, and
   <code class="literal">
    syslog
   </code>
   on Unix and Unix-like systems).
  </p>
  <p>
   This section describes how to configure error logging using the
        built-in filter,
   <code class="literal">
    log_filter_internal
   </code>
   , and the
        system log sink,
   <code class="literal">
    log_sink_syseventlog
   </code>
   , to
        take effect immediately and for subsequent server startups. For
        general information about configuring error logging, see
   <a class="xref" href="error-log-configuration.html" title="7.4.2.1 Error Log Configuration">
    Section 7.4.2.1, “Error Log Configuration”
   </a>
   .
  </p>
  <p>
   To enable the system log sink, first load the sink component,
        then modify the
   <a class="link" href="server-system-variables.html#sysvar_log_error_services">
    <code class="literal">
     log_error_services
    </code>
   </a>
   value:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa34413556"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSTALL</span> <span class="token keyword">COMPONENT</span> <span class="token string">'file://component_log_sink_syseventlog'</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token keyword">PERSIST</span> log_error_services <span class="token operator">=</span> <span class="token string">'log_filter_internal; log_sink_syseventlog'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   To set
   <a class="link" href="server-system-variables.html#sysvar_log_error_services">
    <code class="literal">
     log_error_services
    </code>
   </a>
   to
        take effect at server startup, use the instructions at
   <a class="xref" href="error-log-configuration.html" title="7.4.2.1 Error Log Configuration">
    Section 7.4.2.1, “Error Log Configuration”
   </a>
   . Those instructions
        apply to other error-logging system variables as well.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    Error logging to the system log may require additional system
          configuration. Consult the system log documentation for your
          platform.
   </p>
  </div>
  <p>
   On Windows, error messages written to the Event Log within the
        Application log have these characteristics:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Entries marked as
      <code class="literal">
       Error
      </code>
      ,
      <code class="literal">
       Warning
      </code>
      , and
      <code class="literal">
       Note
      </code>
      are
            written to the Event Log, but not messages such as
            information statements from individual storage engines.
     </p>
    </li>
    <li class="listitem">
     <p>
      Event Log entries have a source of
      <code class="literal">
       MySQL
      </code>
      (or
      <code class="literal">
       MySQL-
       <em class="replaceable">
        <code>
         tag
        </code>
       </em>
      </code>
      if
      <a class="link" href="server-system-variables.html#sysvar_syseventlog.tag">
       <code class="literal">
        syseventlog.tag
       </code>
      </a>
      is
            defined as
      <em class="replaceable">
       <code>
        tag
       </code>
      </em>
      ).
     </p>
    </li>
   </ul>
  </div>
  <p>
   On Unix and Unix-like systems, logging to the system log uses
   <code class="literal">
    syslog
   </code>
   . The following system variables affect
   <code class="literal">
    syslog
   </code>
   messages:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="link" href="server-system-variables.html#sysvar_syseventlog.facility">
       <code class="literal">
        syseventlog.facility
       </code>
      </a>
      : The
            default facility for
      <code class="literal">
       syslog
      </code>
      messages is
      <code class="literal">
       daemon
      </code>
      . Set this variable to specify a
            different facility.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="server-system-variables.html#sysvar_syseventlog.include_pid">
       <code class="literal">
        syseventlog.include_pid
       </code>
      </a>
      :
            Whether to include the server process ID in each line of
      <code class="literal">
       syslog
      </code>
      output.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="server-system-variables.html#sysvar_syseventlog.tag">
       <code class="literal">
        syseventlog.tag
       </code>
      </a>
      : This
            variable defines a tag to add to the server identifier
            (
      <code class="literal">
       mysqld
      </code>
      ) in
      <code class="literal">
       syslog
      </code>
      messages. If defined, the tag is appended to the identifier
            with a leading hyphen.
     </p>
    </li>
   </ul>
  </div>
  <p>
   MySQL uses the custom label
   <span class="quote">
    “
    <span class="quote">
     System
    </span>
    ”
   </span>
   for important
        system messages about non-error situations, such as startup,
        shutdown, and some significant changes to settings. In logs that
        do not support custom labels, including the Event Log on
        Windows, and
   <code class="literal">
    syslog
   </code>
   on Unix and Unix-like
        systems, system messages are assigned the label used for the
        information priority level. However, these messages are printed
        to the log even if the MySQL
   <a class="link" href="server-system-variables.html#sysvar_log_error_verbosity">
    <code class="literal">
     log_error_verbosity
    </code>
   </a>
   setting
        normally excludes messages at the information level.
  </p>
  <p>
   When a log sink must fall back to a label of
   <span class="quote">
    “
    <span class="quote">
     Information
    </span>
    ”
   </span>
   instead of
   <span class="quote">
    “
    <span class="quote">
     System
    </span>
    ”
   </span>
   in
        this way, and the log event is further processed outside of the
        MySQL server (for example, filtered or forwarded by a
   <code class="literal">
    syslog
   </code>
   configuration), these events may by
        default be processed by the secondary application as being of
   <span class="quote">
    “
    <span class="quote">
     Information
    </span>
    ”
   </span>
   priority rather than
   <span class="quote">
    “
    <span class="quote">
     System
    </span>
    ”
   </span>
   priority.
  </p>
 </div>
 <br/>
</div>
