<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h2 class="title">
      <a name="server-logs">
      </a>
      7.4 MySQL Server Logs
     </h2>
    </div>
   </div>
  </div>
  <div class="toc">
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="log-destinations.html">
       7.4.1 Selecting General Query Log and Slow Query Log Output Destinations
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="error-log.html">
       7.4.2 The Error Log
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="query-log.html">
       7.4.3 The General Query Log
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="binary-log.html">
       7.4.4 The Binary Log
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="slow-query-log.html">
       7.4.5 The Slow Query Log
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="log-file-maintenance.html">
       7.4.6 Server Log Maintenance
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <a class="indexterm" name="idm46045259450992">
  </a>
  <a class="indexterm" name="idm46045259449504">
  </a>
  <p>
   MySQL Server has several logs that can help you find out what
    activity is taking place.
  </p>
  <div class="informaltable">
   <table summary="MySQL Server log types and the information written to each log.">
    <colgroup>
     <col style="width: 30%"/>
     <col style="width: 70%"/>
    </colgroup>
    <thead>
     <tr>
      <th>
       Log Type
      </th>
      <th>
       Information Written to Log
      </th>
     </tr>
    </thead>
    <tbody>
     <tr>
      <td>
       Error log
      </td>
      <td>
       Problems encountered starting, running, or stopping
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
      </td>
     </tr>
     <tr>
      <td>
       General query log
      </td>
      <td>
       Established client connections and statements received from clients
      </td>
     </tr>
     <tr>
      <td>
       Binary log
      </td>
      <td>
       Statements that change data (also used for replication)
      </td>
     </tr>
     <tr>
      <td>
       Relay log
      </td>
      <td>
       Data changes received from a replication source server
      </td>
     </tr>
     <tr>
      <td>
       Slow query log
      </td>
      <td>
       Queries that took more than
       <a class="link" href="server-system-variables.html#sysvar_long_query_time">
        <code class="literal">
         long_query_time
        </code>
       </a>
       seconds to
          execute
      </td>
     </tr>
     <tr>
      <td>
       DDL logs
      </td>
      <td>
       Atomic DDL operations performed by DDL statements
      </td>
     </tr>
    </tbody>
   </table>
  </div>
  <p>
   By default, no logs are enabled, except the error log on Windows.
    For information about DDL log behavior, see
   <a class="xref" href="atomic-ddl.html#atomic-ddl-view-logs" title="Viewing DDL Logs">
    Viewing DDL Logs
   </a>
   . The following log-specific
    sections provide information about the server options that enable
    logging.
  </p>
  <a class="indexterm" name="idm46045259425232">
  </a>
  <p>
   By default, the server writes files for all enabled logs in the data
    directory. You can force the server to close and reopen the log
    files (or in some cases switch to a new log file) by flushing the
    logs. Log flushing occurs when you issue a
   <a class="link" href="flush.html#flush-logs">
    <code class="literal">
     FLUSH LOGS
    </code>
   </a>
   statement; execute
   <a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
    <span class="command">
     <strong>
      mysqladmin
     </strong>
    </span>
   </a>
   with a
   <code class="literal">
    flush-logs
   </code>
   or
   <code class="literal">
    refresh
   </code>
   argument; or execute
   <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
    <span class="command">
     <strong>
      mysqldump
     </strong>
    </span>
   </a>
   with a
   <a class="link" href="mysqldump.html#option_mysqldump_flush-logs">
    <code class="option">
     --flush-logs
    </code>
   </a>
   option. See
   <a class="xref" href="flush.html" title="15.7.8.3 FLUSH Statement">
    Section 15.7.8.3, “FLUSH Statement”
   </a>
   ,
   <a class="xref" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
    Section 6.5.2, “mysqladmin — A MySQL Server Administration Program”
   </a>
   , and
   <a class="xref" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
    Section 6.5.4, “mysqldump — A Database Backup Program”
   </a>
   . In addition, the binary log is flushed
    when its size reaches the value of the
   <a class="link" href="replication-options-binary-log.html#sysvar_max_binlog_size">
    <code class="literal">
     max_binlog_size
    </code>
   </a>
   system variable.
  </p>
  <p>
   You can control the general query and slow query logs during
    runtime. You can enable or disable logging, or change the log file
    name. You can tell the server to write general query and slow query
    entries to log tables, log files, or both. For details, see
   <a class="xref" href="log-destinations.html" title="7.4.1 Selecting General Query Log and Slow Query Log Output Destinations">
    Section 7.4.1, “Selecting General Query Log and Slow Query Log Output Destinations”
   </a>
   ,
   <a class="xref" href="query-log.html" title="7.4.3 The General Query Log">
    Section 7.4.3, “The General Query Log”
   </a>
   , and
   <a class="xref" href="slow-query-log.html" title="7.4.5 The Slow Query Log">
    Section 7.4.5, “The Slow Query Log”
   </a>
   .
  </p>
  <p>
   The relay log is used only on replicas, to hold data changes from
    the replication source server that must also be made on the replica.
    For discussion of relay log contents and configuration, see
   <a class="xref" href="replica-logs-relaylog.html" title="19.2.4.1 The Relay Log">
    Section 19.2.4.1, “The Relay Log”
   </a>
   .
  </p>
  <p>
   For information about log maintenance operations such as expiration
    of old log files, see
   <a class="xref" href="log-file-maintenance.html" title="7.4.6 Server Log Maintenance">
    Section 7.4.6, “Server Log Maintenance”
   </a>
   .
  </p>
  <p>
   For information about keeping logs secure, see
   <a class="xref" href="password-logging.html" title="8.1.2.3 Passwords and Logging">
    Section 8.1.2.3, “Passwords and Logging”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
