<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="error-log-format">
      </a>
      7.4.2.9 Error Log Output Format
     </h4>
    </div>
   </div>
  </div>
  <p>
   Each error log sink (writer) component has a characteristic
        output format it uses to write messages to its destination, but
        other factors may influence the content of the messages:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      The information available to the log sink. If a log filter
            component executed prior to execution of the sink component
            removes a log event field, that field is not available for
            writing. For information about log filtering, see
      <a class="xref" href="error-log-filtering.html" title="7.4.2.4 Types of Error Log Filtering">
       Section 7.4.2.4, “Types of Error Log Filtering”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      The information relevant to the log sink. Not every sink
            writes all fields available in error events.
     </p>
    </li>
    <li class="listitem">
     <p>
      System variables may affect log sinks. See
      <a class="xref" href="error-log-format.html#error-log-format-system-variables" title="System Variables That Affect Error Log Format">
       System Variables That Affect Error Log Format
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   For names and descriptions of the fields in error events, see
   <a class="xref" href="error-log-event-fields.html" title="7.4.2.3 Error Event Fields">
    Section 7.4.2.3, “Error Event Fields”
   </a>
   . For all log sinks, the
        thread ID included in error log messages is that of the thread
        within
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   responsible for writing the
        message. This ID indicates which part of the server produced the
        message, and is consistent with general query log and slow query
        log messages, which include the connection thread ID.
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="error-log-format.html#error-log-format-output-format-for-log-sink-internal" title="log_sink_internal Output Format">
       log_sink_internal Output Format
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="error-log-format.html#error-log-format-output-format-for-log-sink-json" title="log_sink_json Output Format">
       log_sink_json Output Format
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="error-log-format.html#error-log-format-output-format-for-log-sink-syseventlog" title="log_sink_syseventlog Output Format">
       log_sink_syseventlog Output Format
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="error-log-format.html#error-log-format-output-format-for-early-logging" title="Early-Startup Logging Output Format">
       Early-Startup Logging Output Format
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="error-log-format.html#error-log-format-system-variables" title="System Variables That Affect Error Log Format">
       System Variables That Affect Error Log Format
      </a>
     </p>
    </li>
   </ul>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="error-log-format-output-format-for-log-sink-internal">
       </a>
       log_sink_internal Output Format
      </h5>
     </div>
    </div>
   </div>
   <p>
    The internal log sink produces traditional error log output.
          For example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-none"><div class="docs-select-all right" id="sa41919266"><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-none">2020-08-06T14:25:02.835618Z 0 [Note] [MY-012487] [InnoDB] DDL log recovery : begin
2020-08-06T14:25:02.936146Z 0 [Warning] [MY-010068] [Server] CA certificate /var/mysql/sslinfo/cacert.pem is self signed.
2020-08-06T14:25:02.963127Z 0 [Note] [MY-010253] [Server] IPv6 is available.
2020-08-06T14:25:03.109022Z 5 [Note] [MY-010051] [Server] Event Scheduler: scheduler thread started with id 5</code></pre>
   </div>
   <p>
    Traditional-format messages have these fields:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa28340468"><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-none">time thread [label] [err_code] [subsystem] msg</code></pre>
   </div>
   <p>
    The
    <code class="literal">
     [
    </code>
    and
    <code class="literal">
     ]
    </code>
    square
          bracket characters are literal characters in the message
          format. They do not indicate that fields are optional.
   </p>
   <p>
    The
    <code class="literal">
     label
    </code>
    value corresponds to the string
          form of the
    <code class="literal">
     prio
    </code>
    error event priority
          field.
   </p>
   <p>
    The
    <code class="literal">
     [err_code]
    </code>
    and
    <code class="literal">
     [subsystem]
    </code>
    fields were added in MySQL 8.0,
          and thus are missing from logs generated by older servers. Log
          parsers can treat these fields as parts of the message text
          that is present only for logs written by servers recent enough
          to include them. Parsers must treat the
    <code class="literal">
     err_code
    </code>
    part of
    <code class="literal">
     [err_code]
    </code>
    indicators as a string value,
          not a number, because values such as
    <code class="literal">
     MY-012487
    </code>
    and
    <code class="literal">
     MY-010051
    </code>
    contain nonnumeric characters.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="error-log-format-output-format-for-log-sink-json">
       </a>
       log_sink_json Output Format
      </h5>
     </div>
    </div>
   </div>
   <p>
    The JSON-format log sink produces messages as JSON objects
          that contain key-value pairs. For example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-json"><div class="docs-select-all right" id="sa34445364"><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-json"><span class="token punctuation">{</span>
  <span class="token property">"prio"</span><span class="token operator">:</span> <span class="token number">3</span><span class="token punctuation">,</span>
  <span class="token property">"err_code"</span><span class="token operator">:</span> <span class="token number">10051</span><span class="token punctuation">,</span>
  <span class="token property">"source_line"</span><span class="token operator">:</span> <span class="token number">561</span><span class="token punctuation">,</span>
  <span class="token property">"source_file"</span><span class="token operator">:</span> <span class="token string">"event_scheduler.cc"</span><span class="token punctuation">,</span>
  <span class="token property">"function"</span><span class="token operator">:</span> <span class="token string">"run"</span><span class="token punctuation">,</span>
  <span class="token property">"msg"</span><span class="token operator">:</span> <span class="token string">"Event Scheduler: scheduler thread started with id 5"</span><span class="token punctuation">,</span>
  <span class="token property">"time"</span><span class="token operator">:</span> <span class="token string">"2020-08-06T14:25:03.109022Z"</span><span class="token punctuation">,</span>
  <span class="token property">"ts"</span><span class="token operator">:</span> <span class="token number">1596724012005</span><span class="token punctuation">,</span>
  <span class="token property">"thread"</span><span class="token operator">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
  <span class="token property">"err_symbol"</span><span class="token operator">:</span> <span class="token string">"ER_SCHEDULER_STARTED"</span><span class="token punctuation">,</span>
  <span class="token property">"SQL_state"</span><span class="token operator">:</span> <span class="token string">"HY000"</span><span class="token punctuation">,</span>
  <span class="token property">"subsystem"</span><span class="token operator">:</span> <span class="token string">"Server"</span><span class="token punctuation">,</span>
  <span class="token property">"buffered"</span><span class="token operator">:</span> <span class="token number">1596723903109022</span><span class="token punctuation">,</span>
  <span class="token property">"label"</span><span class="token operator">:</span> <span class="token string">"Note"</span>
<span class="token punctuation">}</span></code></pre>
   </div>
   <p>
    The message shown is reformatted for readability. Events
          written to the error log appear one message per line.
   </p>
   <a class="indexterm" name="idm46045258468832">
   </a>
   <p>
    The
    <code class="literal">
     ts
    </code>
    (timestamp) key is unique to the
          JSON-format log sink. The value is an integer indicating
          milliseconds since the epoch (
    <code class="literal">
     '1970-01-01
          00:00:00'
    </code>
    UTC).
   </p>
   <p>
    The
    <code class="literal">
     ts
    </code>
    and
    <code class="literal">
     buffered
    </code>
    values are Unix timestamp values and can be converted using
    <a class="link" href="date-and-time-functions.html#function_from-unixtime">
     <code class="literal">
      FROM_UNIXTIME()
     </code>
    </a>
    and an
          appropriate divisor:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa6862414"><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 prompt">mysql&gt;</span> <span class="token keyword">SET</span> time_zone <span class="token operator">=</span> <span class="token string">'+00:00'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">FROM_UNIXTIME</span><span class="token punctuation">(</span><span class="token number">1596724012005</span><span class="token operator">/</span><span class="token number">1000.0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> FROM_UNIXTIME(1596724012005/1000.0) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2020<span class="token punctuation">-</span>08<span class="token punctuation">-</span>06 14:26:52.0050            <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">FROM_UNIXTIME</span><span class="token punctuation">(</span><span class="token number">1596723903109022</span><span class="token operator">/</span><span class="token number">1000000.0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> FROM_UNIXTIME(1596723903109022/1000000.0) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2020<span class="token punctuation">-</span>08<span class="token punctuation">-</span>06 14:25:03.1090                  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="error-log-format-output-format-for-log-sink-syseventlog">
       </a>
       log_sink_syseventlog Output Format
      </h5>
     </div>
    </div>
   </div>
   <p>
    The system log sink produces output that conforms to the
          system log format used on the local platform.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="error-log-format-output-format-for-early-logging">
       </a>
       Early-Startup Logging Output Format
      </h5>
     </div>
    </div>
   </div>
   <p>
    The server generates some error log messages before startup
          options have been processed, and thus before it knows error
          log settings such as the
    <a class="link" href="server-system-variables.html#sysvar_log_error_verbosity">
     <code class="literal">
      log_error_verbosity
     </code>
    </a>
    and
    <a class="link" href="server-system-variables.html#sysvar_log_timestamps">
     <code class="literal">
      log_timestamps
     </code>
    </a>
    system
          variable values, and before it knows which log components are
          to be used. The server handles error log messages that are
          generated early in the startup process as follows:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       The server buffers log events (rather than formatted log
              messages), which enables it to apply configuration
              settings to those events retroactively, after the settings
              are known, with the result that flushed messages use the
              configured settings, not the defaults. Also, messages are
              flushed to all configured sinks, not just the default
              sink.
      </p>
      <p>
       If a fatal error occurs before log configuration is known
              and the server must exit, the server formats buffered
              messages using the logging defaults so they are not lost.
              If no fatal error occurs but startup is excessively slow
              prior to processing startup options, the server
              periodically formats and flushes buffered messages using
              the logging defaults so as not to appear unresponsive.
              Although this behavior uses the defaults, it is preferable
              to losing messages when exceptional conditions occur.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="error-log-format-system-variables">
       </a>
       System Variables That Affect Error Log Format
      </h5>
     </div>
    </div>
   </div>
   <p>
    The
    <a class="link" href="server-system-variables.html#sysvar_log_timestamps">
     <code class="literal">
      log_timestamps
     </code>
    </a>
    system
          variable controls the time zone of timestamps in messages
          written to the error log (as well as to general query log and
          slow query log files). The server applies
    <a class="link" href="server-system-variables.html#sysvar_log_timestamps">
     <code class="literal">
      log_timestamps
     </code>
    </a>
    to error
          events before they reach any log sink; it thus affects error
          message output from all sinks.
   </p>
   <p>
    Permitted
    <a class="link" href="server-system-variables.html#sysvar_log_timestamps">
     <code class="literal">
      log_timestamps
     </code>
    </a>
    values are
    <code class="literal">
     UTC
    </code>
    (the default) and
    <code class="literal">
     SYSTEM
    </code>
    (the local system time zone).
          Timestamps are written using ISO 8601 / RFC 3339 format:
    <code class="literal">
     <em class="replaceable">
      <code>
       YYYY-MM-DD
      </code>
     </em>
     T
     <em class="replaceable">
      <code>
       hh:mm:ss.uuuuuu
      </code>
     </em>
    </code>
    plus a tail value of
    <code class="literal">
     Z
    </code>
    signifying Zulu time
          (UTC) or
    <code class="literal">
     ±hh:mm
    </code>
    (an offset that
          indicates the local system time zone adjustment relative to
          UTC). For example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-none"><div class="docs-select-all right" id="sa21644527"><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-none">2020-08-07T15:02:00.832521Z            (UTC)
2020-08-07T10:02:00.832521-05:00       (SYSTEM)</code></pre>
   </div>
  </div>
 </div>
 <br/>
</div>
