403Webshell
Server IP : 103.119.228.120  /  Your IP : 3.141.21.199
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /usr/share/doc/postgresql-9.2.24/html/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/share/doc/postgresql-9.2.24/html/runtime-config-logging.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Error Reporting and Logging</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.2.24 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Server Configuration"
HREF="runtime-config.html"><LINK
REL="PREVIOUS"
TITLE="Query Planning"
HREF="runtime-config-query.html"><LINK
REL="NEXT"
TITLE="Run-time Statistics"
HREF="runtime-config-statistics.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2017-11-06T22:43:11"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.2.24 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="Query Planning"
HREF="runtime-config-query.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="runtime-config.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 18. Server Configuration</TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="Run-time Statistics"
HREF="runtime-config-statistics.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="RUNTIME-CONFIG-LOGGING"
>18.8. Error Reporting and Logging</A
></H1
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="RUNTIME-CONFIG-LOGGING-WHERE"
>18.8.1. Where To Log</A
></H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><A
NAME="GUC-LOG-DESTINATION"
></A
><TT
CLASS="VARNAME"
>log_destination</TT
> (<TT
CLASS="TYPE"
>string</TT
>)</DT
><DD
><P
>        <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> supports several methods
         for logging server messages, including
         <SPAN
CLASS="SYSTEMITEM"
>stderr</SPAN
>, <SPAN
CLASS="SYSTEMITEM"
>csvlog</SPAN
> and
         <SPAN
CLASS="SYSTEMITEM"
>syslog</SPAN
>. On Windows,
         <SPAN
CLASS="SYSTEMITEM"
>eventlog</SPAN
> is also supported. Set this
         parameter to a list of desired log destinations separated by
         commas. The default is to log to <SPAN
CLASS="SYSTEMITEM"
>stderr</SPAN
>
         only.
         This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
         file or on the server command line.
       </P
><P
>        If <SPAN
CLASS="SYSTEMITEM"
>csvlog</SPAN
> is included in <TT
CLASS="VARNAME"
>log_destination</TT
>,
        log entries are output in <SPAN
CLASS="QUOTE"
>"comma separated
        value"</SPAN
> (<ACRONYM
CLASS="ACRONYM"
>CSV</ACRONYM
>) format, which is convenient for
        loading logs into programs.
        See <A
HREF="runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG"
>Section 18.8.4</A
> for details.
        <A
HREF="runtime-config-logging.html#GUC-LOGGING-COLLECTOR"
>logging_collector</A
> must be enabled to generate
        CSV-format log output.
       </P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>         On most Unix systems, you will need to alter the configuration of
         your system's <SPAN
CLASS="APPLICATION"
>syslog</SPAN
> daemon in order
         to make use of the <SPAN
CLASS="SYSTEMITEM"
>syslog</SPAN
> option for
         <TT
CLASS="VARNAME"
>log_destination</TT
>.  <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
>
         can log to <SPAN
CLASS="APPLICATION"
>syslog</SPAN
> facilities
         <TT
CLASS="LITERAL"
>LOCAL0</TT
> through <TT
CLASS="LITERAL"
>LOCAL7</TT
> (see <A
HREF="runtime-config-logging.html#GUC-SYSLOG-FACILITY"
>syslog_facility</A
>), but the default
         <SPAN
CLASS="APPLICATION"
>syslog</SPAN
> configuration on most platforms
         will discard all such messages.  You will need to add something like:
</P><PRE
CLASS="PROGRAMLISTING"
>local0.*    /var/log/postgresql</PRE
><P>
         to the  <SPAN
CLASS="APPLICATION"
>syslog</SPAN
> daemon's configuration file
         to make it work.
        </P
><P
>         On Windows, when you use the <TT
CLASS="LITERAL"
>eventlog</TT
>
         option for <TT
CLASS="VARNAME"
>log_destination</TT
>, you should
         register an event source and its library with the operating
         system so that the Windows Event Viewer can display event
         log messages cleanly.
         See <A
HREF="event-log-registration.html"
>Section 17.11</A
> for details.
        </P
></BLOCKQUOTE
></DIV
></DD
><DT
><A
NAME="GUC-LOGGING-COLLECTOR"
></A
><TT
CLASS="VARNAME"
>logging_collector</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)</DT
><DD
><P
>         This parameter enables the <I
CLASS="FIRSTTERM"
>logging collector</I
>, which
         is a background process that captures log messages
         sent to <SPAN
CLASS="SYSTEMITEM"
>stderr</SPAN
> and redirects them into log files.
         This approach is often more useful than
         logging to <SPAN
CLASS="APPLICATION"
>syslog</SPAN
>, since some types of messages
         might not appear in <SPAN
CLASS="APPLICATION"
>syslog</SPAN
> output.  (One common
         example is dynamic-linker failure messages; another is error messages
         produced by scripts such as <TT
CLASS="VARNAME"
>archive_command</TT
>.)
         This parameter can only be set at server start.
       </P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>         It is possible to log to <SPAN
CLASS="SYSTEMITEM"
>stderr</SPAN
> without using the
         logging collector; the log messages will just go to wherever the
         server's <SPAN
CLASS="SYSTEMITEM"
>stderr</SPAN
> is directed.  However, that method is
         only suitable for low log volumes, since it provides no convenient
         way to rotate log files.  Also, on some platforms not using the
         logging collector can result in lost or garbled log output, because
         multiple processes writing concurrently to the same log file can
         overwrite each other's output.
        </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>          The logging collector is designed to never lose messages.  This means
          that in case of extremely high load, server processes could be
          blocked while trying to send additional log messages when the
          collector has fallen behind.  In contrast, <SPAN
CLASS="APPLICATION"
>syslog</SPAN
>
          prefers to drop messages if it cannot write them, which means it
          may fail to log some messages in such cases but it will not block
          the rest of the system.
        </P
></BLOCKQUOTE
></DIV
></DD
><DT
><A
NAME="GUC-LOG-DIRECTORY"
></A
><TT
CLASS="VARNAME"
>log_directory</TT
> (<TT
CLASS="TYPE"
>string</TT
>)</DT
><DD
><P
>        When <TT
CLASS="VARNAME"
>logging_collector</TT
> is enabled,
        this parameter determines the directory in which log files will be created.
        It can be specified as an absolute path, or relative to the
        cluster data directory.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
        The default is <TT
CLASS="LITERAL"
>pg_log</TT
>.
       </P
></DD
><DT
><A
NAME="GUC-LOG-FILENAME"
></A
><TT
CLASS="VARNAME"
>log_filename</TT
> (<TT
CLASS="TYPE"
>string</TT
>)</DT
><DD
><P
>        When <TT
CLASS="VARNAME"
>logging_collector</TT
> is enabled,
        this parameter sets the file names of the created log files.  The value
        is treated as a <SPAN
CLASS="SYSTEMITEM"
>strftime</SPAN
> pattern,
        so <TT
CLASS="LITERAL"
>%</TT
>-escapes can be used to specify time-varying
        file names.  (Note that if there are
        any time-zone-dependent <TT
CLASS="LITERAL"
>%</TT
>-escapes, the computation
        is done in the zone specified
        by <A
HREF="runtime-config-logging.html#GUC-LOG-TIMEZONE"
>log_timezone</A
>.)
        The supported <TT
CLASS="LITERAL"
>%</TT
>-escapes are similar to those
        listed in the Open Group's <A
HREF="http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html"
TARGET="_top"
>strftime
        </A
> specification.
        Note that the system's <SPAN
CLASS="SYSTEMITEM"
>strftime</SPAN
> is not used
        directly, so platform-specific (nonstandard) extensions do not work.
        The default is <TT
CLASS="LITERAL"
>postgresql-%Y-%m-%d_%H%M%S.log</TT
>.
       </P
><P
>        If you specify a file name without escapes, you should plan to
        use a log rotation utility to avoid eventually filling the
        entire disk.  In releases prior to 8.4, if
        no <TT
CLASS="LITERAL"
>%</TT
> escapes were
        present, <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> would append
        the epoch of the new log file's creation time, but this is no
        longer the case.
       </P
><P
>        If CSV-format output is enabled in <TT
CLASS="VARNAME"
>log_destination</TT
>,
        <TT
CLASS="LITERAL"
>.csv</TT
> will be appended to the timestamped
        log file name to create the file name for CSV-format output.
        (If <TT
CLASS="VARNAME"
>log_filename</TT
> ends in <TT
CLASS="LITERAL"
>.log</TT
>, the suffix is
        replaced instead.)
       </P
><P
>        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-LOG-FILE-MODE"
></A
><TT
CLASS="VARNAME"
>log_file_mode</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)</DT
><DD
><P
>        On Unix systems this parameter sets the permissions for log files
        when <TT
CLASS="VARNAME"
>logging_collector</TT
> is enabled. (On Microsoft
        Windows this parameter is ignored.)
        The parameter value is expected to be a numeric mode
        specified in the format accepted by the
        <CODE
CLASS="FUNCTION"
>chmod</CODE
> and <CODE
CLASS="FUNCTION"
>umask</CODE
>
        system calls.  (To use the customary octal format the number
        must start with a <TT
CLASS="LITERAL"
>0</TT
> (zero).)
       </P
><P
>        The default permissions are <TT
CLASS="LITERAL"
>0600</TT
>, meaning only the
        server owner can read or write the log files.  The other commonly
        useful setting is <TT
CLASS="LITERAL"
>0640</TT
>, allowing members of the owner's
        group to read the files.  Note however that to make use of such a
        setting, you'll need to alter <A
HREF="runtime-config-logging.html#GUC-LOG-DIRECTORY"
>log_directory</A
> to
        store the files somewhere outside the cluster data directory.  In
        any case, it's unwise to make the log files world-readable, since
        they might contain sensitive data.
       </P
><P
>        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-LOG-ROTATION-AGE"
></A
><TT
CLASS="VARNAME"
>log_rotation_age</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)</DT
><DD
><P
>        When <TT
CLASS="VARNAME"
>logging_collector</TT
> is enabled,
        this parameter determines the maximum lifetime of an individual log file.
        After this many minutes have elapsed, a new log file will
        be created.  Set to zero to disable time-based creation of
        new log files.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-LOG-ROTATION-SIZE"
></A
><TT
CLASS="VARNAME"
>log_rotation_size</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)</DT
><DD
><P
>        When <TT
CLASS="VARNAME"
>logging_collector</TT
> is enabled,
        this parameter determines the maximum size of an individual log file.
        After this many kilobytes have been emitted into a log file,
        a new log file will be created.  Set to zero to disable size-based
        creation of new log files.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-LOG-TRUNCATE-ON-ROTATION"
></A
><TT
CLASS="VARNAME"
>log_truncate_on_rotation</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)</DT
><DD
><P
>        When <TT
CLASS="VARNAME"
>logging_collector</TT
> is enabled,
        this parameter will cause <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> to truncate (overwrite),
        rather than append to, any existing log file of the same name.
        However, truncation will occur only when a new file is being opened
        due to time-based rotation, not during server startup or size-based
        rotation.  When off, pre-existing files will be appended to in
        all cases.  For example, using this setting in combination with
        a <TT
CLASS="VARNAME"
>log_filename</TT
> like <TT
CLASS="LITERAL"
>postgresql-%H.log</TT
>
        would result in generating twenty-four hourly log files and then
        cyclically overwriting them.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
><P
>        Example:  To keep 7 days of logs, one log file per day named
        <TT
CLASS="LITERAL"
>server_log.Mon</TT
>, <TT
CLASS="LITERAL"
>server_log.Tue</TT
>,
        etc, and automatically overwrite last week's log with this week's log,
        set <TT
CLASS="VARNAME"
>log_filename</TT
> to <TT
CLASS="LITERAL"
>server_log.%a</TT
>,
        <TT
CLASS="VARNAME"
>log_truncate_on_rotation</TT
> to <TT
CLASS="LITERAL"
>on</TT
>, and
        <TT
CLASS="VARNAME"
>log_rotation_age</TT
> to <TT
CLASS="LITERAL"
>1440</TT
>.
       </P
><P
>        Example: To keep 24 hours of logs, one log file per hour, but
        also rotate sooner if the log file size exceeds 1GB, set
        <TT
CLASS="VARNAME"
>log_filename</TT
> to <TT
CLASS="LITERAL"
>server_log.%H%M</TT
>,
        <TT
CLASS="VARNAME"
>log_truncate_on_rotation</TT
> to <TT
CLASS="LITERAL"
>on</TT
>,
        <TT
CLASS="VARNAME"
>log_rotation_age</TT
> to <TT
CLASS="LITERAL"
>60</TT
>, and
        <TT
CLASS="VARNAME"
>log_rotation_size</TT
> to <TT
CLASS="LITERAL"
>1000000</TT
>.
        Including <TT
CLASS="LITERAL"
>%M</TT
> in <TT
CLASS="VARNAME"
>log_filename</TT
> allows
        any size-driven rotations that might occur to select a file name
        different from the hour's initial file name.
       </P
></DD
><DT
><A
NAME="GUC-SYSLOG-FACILITY"
></A
><TT
CLASS="VARNAME"
>syslog_facility</TT
> (<TT
CLASS="TYPE"
>enum</TT
>)</DT
><DD
><P
>        When logging to <SPAN
CLASS="APPLICATION"
>syslog</SPAN
> is enabled, this parameter
        determines the <SPAN
CLASS="APPLICATION"
>syslog</SPAN
>
        <SPAN
CLASS="QUOTE"
>"facility"</SPAN
> to be used.  You can choose
        from <TT
CLASS="LITERAL"
>LOCAL0</TT
>, <TT
CLASS="LITERAL"
>LOCAL1</TT
>,
        <TT
CLASS="LITERAL"
>LOCAL2</TT
>, <TT
CLASS="LITERAL"
>LOCAL3</TT
>, <TT
CLASS="LITERAL"
>LOCAL4</TT
>,
        <TT
CLASS="LITERAL"
>LOCAL5</TT
>, <TT
CLASS="LITERAL"
>LOCAL6</TT
>, <TT
CLASS="LITERAL"
>LOCAL7</TT
>;
        the default is <TT
CLASS="LITERAL"
>LOCAL0</TT
>. See also the
        documentation of your system's
        <SPAN
CLASS="APPLICATION"
>syslog</SPAN
> daemon.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-SYSLOG-IDENT"
></A
><TT
CLASS="VARNAME"
>syslog_ident</TT
> (<TT
CLASS="TYPE"
>string</TT
>)</DT
><DD
><P
>         When logging to <SPAN
CLASS="APPLICATION"
>syslog</SPAN
> is enabled, this parameter
         determines the program name used to identify
         <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> messages in
         <SPAN
CLASS="APPLICATION"
>syslog</SPAN
> logs. The default is
         <TT
CLASS="LITERAL"
>postgres</TT
>.
         This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
         file or on the server command line.
        </P
></DD
><DT
><A
NAME="GUC-EVENT-SOURCE"
></A
><TT
CLASS="VARNAME"
>event_source</TT
> (<TT
CLASS="TYPE"
>string</TT
>)</DT
><DD
><P
>        When logging to <SPAN
CLASS="APPLICATION"
>event log</SPAN
> is enabled, this parameter
        determines the program name used to identify
        <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> messages in
        the log. The default is <TT
CLASS="LITERAL"
>PostgreSQL</TT
>.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="RUNTIME-CONFIG-LOGGING-WHEN"
>18.8.2. When To Log</A
></H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><A
NAME="GUC-CLIENT-MIN-MESSAGES"
></A
><TT
CLASS="VARNAME"
>client_min_messages</TT
> (<TT
CLASS="TYPE"
>enum</TT
>)</DT
><DD
><P
>        Controls which message levels are sent to the client.
        Valid values are <TT
CLASS="LITERAL"
>DEBUG5</TT
>,
        <TT
CLASS="LITERAL"
>DEBUG4</TT
>, <TT
CLASS="LITERAL"
>DEBUG3</TT
>, <TT
CLASS="LITERAL"
>DEBUG2</TT
>,
        <TT
CLASS="LITERAL"
>DEBUG1</TT
>, <TT
CLASS="LITERAL"
>LOG</TT
>, <TT
CLASS="LITERAL"
>NOTICE</TT
>,
        <TT
CLASS="LITERAL"
>WARNING</TT
>, <TT
CLASS="LITERAL"
>ERROR</TT
>, <TT
CLASS="LITERAL"
>FATAL</TT
>,
        and <TT
CLASS="LITERAL"
>PANIC</TT
>.  Each level
        includes all the levels that follow it.  The later the level,
        the fewer messages are sent.  The default is
        <TT
CLASS="LITERAL"
>NOTICE</TT
>.  Note that <TT
CLASS="LITERAL"
>LOG</TT
> has a different
        rank here than in <TT
CLASS="VARNAME"
>log_min_messages</TT
>.
       </P
></DD
><DT
><A
NAME="GUC-LOG-MIN-MESSAGES"
></A
><TT
CLASS="VARNAME"
>log_min_messages</TT
> (<TT
CLASS="TYPE"
>enum</TT
>)</DT
><DD
><P
>        Controls which message levels are written to the server log.
        Valid values are <TT
CLASS="LITERAL"
>DEBUG5</TT
>, <TT
CLASS="LITERAL"
>DEBUG4</TT
>,
        <TT
CLASS="LITERAL"
>DEBUG3</TT
>, <TT
CLASS="LITERAL"
>DEBUG2</TT
>, <TT
CLASS="LITERAL"
>DEBUG1</TT
>,
        <TT
CLASS="LITERAL"
>INFO</TT
>, <TT
CLASS="LITERAL"
>NOTICE</TT
>, <TT
CLASS="LITERAL"
>WARNING</TT
>,
        <TT
CLASS="LITERAL"
>ERROR</TT
>, <TT
CLASS="LITERAL"
>LOG</TT
>, <TT
CLASS="LITERAL"
>FATAL</TT
>, and
        <TT
CLASS="LITERAL"
>PANIC</TT
>.  Each level includes all the levels that
        follow it.  The later the level, the fewer messages are sent
        to the log.  The default is <TT
CLASS="LITERAL"
>WARNING</TT
>.  Note that
        <TT
CLASS="LITERAL"
>LOG</TT
> has a different rank here than in
        <TT
CLASS="VARNAME"
>client_min_messages</TT
>.
        Only superusers can change this setting.
       </P
></DD
><DT
><A
NAME="GUC-LOG-MIN-ERROR-STATEMENT"
></A
><TT
CLASS="VARNAME"
>log_min_error_statement</TT
> (<TT
CLASS="TYPE"
>enum</TT
>)</DT
><DD
><P
>        Controls which SQL statements that cause an error
        condition are recorded in the server log.  The current
        SQL statement is included in the log entry for any message of
        the specified severity or higher.
        Valid values are <TT
CLASS="LITERAL"
>DEBUG5</TT
>,
        <TT
CLASS="LITERAL"
>DEBUG4</TT
>, <TT
CLASS="LITERAL"
>DEBUG3</TT
>,
        <TT
CLASS="LITERAL"
>DEBUG2</TT
>, <TT
CLASS="LITERAL"
>DEBUG1</TT
>,
        <TT
CLASS="LITERAL"
>INFO</TT
>, <TT
CLASS="LITERAL"
>NOTICE</TT
>,
        <TT
CLASS="LITERAL"
>WARNING</TT
>, <TT
CLASS="LITERAL"
>ERROR</TT
>,
        <TT
CLASS="LITERAL"
>LOG</TT
>,
        <TT
CLASS="LITERAL"
>FATAL</TT
>, and <TT
CLASS="LITERAL"
>PANIC</TT
>.
        The default is <TT
CLASS="LITERAL"
>ERROR</TT
>, which means statements
        causing errors, log messages, fatal errors, or panics will be logged.
        To effectively turn off logging of failing statements,
        set this parameter to <TT
CLASS="LITERAL"
>PANIC</TT
>.
        Only superusers can change this setting.
       </P
></DD
><DT
><A
NAME="GUC-LOG-MIN-DURATION-STATEMENT"
></A
><TT
CLASS="VARNAME"
>log_min_duration_statement</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)</DT
><DD
><P
>         Causes the duration of each completed statement to be logged
         if the statement ran for at least the specified number of
         milliseconds.  Setting this to zero prints all statement durations.
         Minus-one (the default) disables logging statement durations.
         For example, if you set it to <TT
CLASS="LITERAL"
>250ms</TT
>
         then all SQL statements that run 250ms or longer will be
         logged.  Enabling this parameter can be helpful in tracking down
         unoptimized queries in your applications.
         Only superusers can change this setting.
        </P
><P
>         For clients using extended query protocol, durations of the Parse,
         Bind, and Execute steps are logged independently.
        </P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>         When using this option together with
         <A
HREF="runtime-config-logging.html#GUC-LOG-STATEMENT"
>log_statement</A
>,
         the text of statements that are logged because of
         <TT
CLASS="VARNAME"
>log_statement</TT
> will not be repeated in the
         duration log message.
         If you are not using <SPAN
CLASS="APPLICATION"
>syslog</SPAN
>, it is recommended
         that you log the PID or session ID using
         <A
HREF="runtime-config-logging.html#GUC-LOG-LINE-PREFIX"
>log_line_prefix</A
>
         so that you can link the statement message to the later
         duration message using the process ID or session ID.
        </P
></BLOCKQUOTE
></DIV
></DD
></DL
></DIV
><P
>     <A
HREF="runtime-config-logging.html#RUNTIME-CONFIG-SEVERITY-LEVELS"
>Table 18-1</A
> explains the message
     severity levels used by <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
>.  If logging output
     is sent to <SPAN
CLASS="SYSTEMITEM"
>syslog</SPAN
> or Windows'
     <SPAN
CLASS="SYSTEMITEM"
>eventlog</SPAN
>, the severity levels are translated
     as shown in the table.
    </P
><DIV
CLASS="TABLE"
><A
NAME="RUNTIME-CONFIG-SEVERITY-LEVELS"
></A
><P
><B
>Table 18-1. Message Severity Levels</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><COL><THEAD
><TR
><TH
>Severity</TH
><TH
>Usage</TH
><TH
><SPAN
CLASS="SYSTEMITEM"
>syslog</SPAN
></TH
><TH
><SPAN
CLASS="SYSTEMITEM"
>eventlog</SPAN
></TH
></TR
></THEAD
><TBODY
><TR
><TD
><TT
CLASS="LITERAL"
>DEBUG1..DEBUG5</TT
></TD
><TD
>Provides successively-more-detailed information for use by
         developers.</TD
><TD
><TT
CLASS="LITERAL"
>DEBUG</TT
></TD
><TD
><TT
CLASS="LITERAL"
>INFORMATION</TT
></TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>INFO</TT
></TD
><TD
>Provides information implicitly requested by the user,
         e.g., output from <TT
CLASS="COMMAND"
>VACUUM VERBOSE</TT
>.</TD
><TD
><TT
CLASS="LITERAL"
>INFO</TT
></TD
><TD
><TT
CLASS="LITERAL"
>INFORMATION</TT
></TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>NOTICE</TT
></TD
><TD
>Provides information that might be helpful to users, e.g.,
         notice of truncation of long identifiers.</TD
><TD
><TT
CLASS="LITERAL"
>NOTICE</TT
></TD
><TD
><TT
CLASS="LITERAL"
>INFORMATION</TT
></TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>WARNING</TT
></TD
><TD
>Provides warnings of likely problems, e.g., <TT
CLASS="COMMAND"
>COMMIT</TT
>
         outside a transaction block.</TD
><TD
><TT
CLASS="LITERAL"
>NOTICE</TT
></TD
><TD
><TT
CLASS="LITERAL"
>WARNING</TT
></TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>ERROR</TT
></TD
><TD
>Reports an error that caused the current command to
         abort.</TD
><TD
><TT
CLASS="LITERAL"
>WARNING</TT
></TD
><TD
><TT
CLASS="LITERAL"
>ERROR</TT
></TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>LOG</TT
></TD
><TD
>Reports information of interest to administrators, e.g.,
         checkpoint activity.</TD
><TD
><TT
CLASS="LITERAL"
>INFO</TT
></TD
><TD
><TT
CLASS="LITERAL"
>INFORMATION</TT
></TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>FATAL</TT
></TD
><TD
>Reports an error that caused the current session to
         abort.</TD
><TD
><TT
CLASS="LITERAL"
>ERR</TT
></TD
><TD
><TT
CLASS="LITERAL"
>ERROR</TT
></TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>PANIC</TT
></TD
><TD
>Reports an error that caused all database sessions to abort.</TD
><TD
><TT
CLASS="LITERAL"
>CRIT</TT
></TD
><TD
><TT
CLASS="LITERAL"
>ERROR</TT
></TD
></TR
></TBODY
></TABLE
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="RUNTIME-CONFIG-LOGGING-WHAT"
>18.8.3. What To Log</A
></H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><A
NAME="GUC-APPLICATION-NAME"
></A
><TT
CLASS="VARNAME"
>application_name</TT
> (<TT
CLASS="TYPE"
>string</TT
>)</DT
><DD
><P
>        The <TT
CLASS="VARNAME"
>application_name</TT
> can be any string of less than
        <TT
CLASS="SYMBOL"
>NAMEDATALEN</TT
> characters (64 characters in a standard build).
        It is typically set by an application upon connection to the server.
        The name will be displayed in the <TT
CLASS="STRUCTNAME"
>pg_stat_activity</TT
> view
        and included in CSV log entries.  It can also be included in regular
        log entries via the <A
HREF="runtime-config-logging.html#GUC-LOG-LINE-PREFIX"
>log_line_prefix</A
> parameter.
        Only printable ASCII characters may be used in the
        <TT
CLASS="VARNAME"
>application_name</TT
> value. Other characters will be
        replaced with question marks (<TT
CLASS="LITERAL"
>?</TT
>).
       </P
></DD
><DT
><TT
CLASS="VARNAME"
>debug_print_parse</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)<BR><TT
CLASS="VARNAME"
>debug_print_rewritten</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)<BR><TT
CLASS="VARNAME"
>debug_print_plan</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)</DT
><DD
><P
>        These parameters enable various debugging output to be emitted.
        When set, they print the resulting parse tree, the query rewriter
        output, or the execution plan for each executed query.
        These messages are emitted at <TT
CLASS="LITERAL"
>LOG</TT
> message level, so by
        default they will appear in the server log but will not be sent to the
        client.  You can change that by adjusting
        <A
HREF="runtime-config-logging.html#GUC-CLIENT-MIN-MESSAGES"
>client_min_messages</A
> and/or
        <A
HREF="runtime-config-logging.html#GUC-LOG-MIN-MESSAGES"
>log_min_messages</A
>.
        These parameters are off by default.
       </P
></DD
><DT
><TT
CLASS="VARNAME"
>debug_pretty_print</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)</DT
><DD
><P
>        When set, <TT
CLASS="VARNAME"
>debug_pretty_print</TT
> indents the messages
        produced by <TT
CLASS="VARNAME"
>debug_print_parse</TT
>,
        <TT
CLASS="VARNAME"
>debug_print_rewritten</TT
>, or
        <TT
CLASS="VARNAME"
>debug_print_plan</TT
>.  This results in more readable
        but much longer output than the <SPAN
CLASS="QUOTE"
>"compact"</SPAN
> format used when
        it is off.  It is on by default.
       </P
></DD
><DT
><A
NAME="GUC-LOG-CHECKPOINTS"
></A
><TT
CLASS="VARNAME"
>log_checkpoints</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)</DT
><DD
><P
>        Causes checkpoints and restartpoints to be logged in the server log.
        Some statistics are included in the log messages, including the number
        of buffers written and the time spent writing them.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line. The default is off.
       </P
></DD
><DT
><A
NAME="GUC-LOG-CONNECTIONS"
></A
><TT
CLASS="VARNAME"
>log_connections</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)</DT
><DD
><P
>        Causes each attempted connection to the server to be logged,
        as well as successful completion of client authentication.
        This parameter cannot be changed after session start.
        The default is off.
       </P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>         Some client programs, like <SPAN
CLASS="APPLICATION"
>psql</SPAN
>, attempt
         to connect twice while determining if a password is required, so
         duplicate <SPAN
CLASS="QUOTE"
>"connection received"</SPAN
> messages do not
         necessarily indicate a problem.
        </P
></BLOCKQUOTE
></DIV
></DD
><DT
><A
NAME="GUC-LOG-DISCONNECTIONS"
></A
><TT
CLASS="VARNAME"
>log_disconnections</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)</DT
><DD
><P
>        This outputs a line in the server log similar to
        <TT
CLASS="VARNAME"
>log_connections</TT
> but at session termination,
        and includes the duration of the session.  This is off by
        default.
        This parameter cannot be changed after session start.
       </P
></DD
><DT
><A
NAME="GUC-LOG-DURATION"
></A
><TT
CLASS="VARNAME"
>log_duration</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)</DT
><DD
><P
>        Causes the duration of every completed statement to be logged.
        The default is <TT
CLASS="LITERAL"
>off</TT
>.
        Only superusers can change this setting.
       </P
><P
>        For clients using extended query protocol, durations of the Parse,
        Bind, and Execute steps are logged independently.
       </P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>         The difference between setting this option and setting
         <A
HREF="runtime-config-logging.html#GUC-LOG-MIN-DURATION-STATEMENT"
>log_min_duration_statement</A
> to zero is that
         exceeding <TT
CLASS="VARNAME"
>log_min_duration_statement</TT
> forces the text of
         the query to be logged, but this option doesn't.  Thus, if
         <TT
CLASS="VARNAME"
>log_duration</TT
> is <TT
CLASS="LITERAL"
>on</TT
> and
         <TT
CLASS="VARNAME"
>log_min_duration_statement</TT
> has a positive value, all
         durations are logged but the query text is included only for
         statements exceeding the threshold.  This behavior can be useful for
         gathering statistics in high-load installations.
        </P
></BLOCKQUOTE
></DIV
></DD
><DT
><A
NAME="GUC-LOG-ERROR-VERBOSITY"
></A
><TT
CLASS="VARNAME"
>log_error_verbosity</TT
> (<TT
CLASS="TYPE"
>enum</TT
>)</DT
><DD
><P
>        Controls the amount of detail written in the server log for each
        message that is logged.  Valid values are <TT
CLASS="LITERAL"
>TERSE</TT
>,
        <TT
CLASS="LITERAL"
>DEFAULT</TT
>, and <TT
CLASS="LITERAL"
>VERBOSE</TT
>, each adding more
        fields to displayed messages.  <TT
CLASS="LITERAL"
>TERSE</TT
> excludes
        the logging of <TT
CLASS="LITERAL"
>DETAIL</TT
>, <TT
CLASS="LITERAL"
>HINT</TT
>,
        <TT
CLASS="LITERAL"
>QUERY</TT
>, and <TT
CLASS="LITERAL"
>CONTEXT</TT
> error information.
        <TT
CLASS="LITERAL"
>VERBOSE</TT
> output includes the <TT
CLASS="SYMBOL"
>SQLSTATE</TT
> error
        code (see also <A
HREF="errcodes-appendix.html"
>Appendix A</A
>) and the source code file name, function name,
        and line number that generated the error.
        Only superusers can change this setting.
       </P
></DD
><DT
><A
NAME="GUC-LOG-HOSTNAME"
></A
><TT
CLASS="VARNAME"
>log_hostname</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)</DT
><DD
><P
>        By default, connection log messages only show the IP address of the
        connecting host. Turning this parameter on causes logging of the
        host name as well.  Note that depending on your host name resolution
        setup this might impose a non-negligible performance penalty.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
><DT
><A
NAME="GUC-LOG-LINE-PREFIX"
></A
><TT
CLASS="VARNAME"
>log_line_prefix</TT
> (<TT
CLASS="TYPE"
>string</TT
>)</DT
><DD
><P
>         This is a <CODE
CLASS="FUNCTION"
>printf</CODE
>-style string that is output at the
         beginning of each log line.
         <TT
CLASS="LITERAL"
>%</TT
> characters begin <SPAN
CLASS="QUOTE"
>"escape sequences"</SPAN
>
         that are replaced with status information as outlined below.
         Unrecognized escapes are ignored. Other
         characters are copied straight to the log line. Some escapes are
         only recognized by session processes, and are ignored by
         background processes such as the main server process.
         This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
         file or on the server command line. The default is an empty string.

         <DIV
CLASS="INFORMALTABLE"
><P
></P
><A
NAME="AEN29710"
></A
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><THEAD
><TR
><TH
>Escape</TH
><TH
>Effect</TH
><TH
>Session only</TH
></TR
></THEAD
><TBODY
><TR
><TD
><TT
CLASS="LITERAL"
>%a</TT
></TD
><TD
>Application name</TD
><TD
>yes</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%u</TT
></TD
><TD
>User name</TD
><TD
>yes</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%d</TT
></TD
><TD
>Database name</TD
><TD
>yes</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%r</TT
></TD
><TD
>Remote host name or IP address, and remote port</TD
><TD
>yes</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%h</TT
></TD
><TD
>Remote host name or IP address</TD
><TD
>yes</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%p</TT
></TD
><TD
>Process ID</TD
><TD
>no</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%t</TT
></TD
><TD
>Time stamp without milliseconds</TD
><TD
>no</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%m</TT
></TD
><TD
>Time stamp with milliseconds</TD
><TD
>no</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%i</TT
></TD
><TD
>Command tag: type of session's current command</TD
><TD
>yes</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%e</TT
></TD
><TD
>SQLSTATE error code</TD
><TD
>no</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%c</TT
></TD
><TD
>Session ID: see below</TD
><TD
>no</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%l</TT
></TD
><TD
>Number of the log line for each session or process, starting at 1</TD
><TD
>no</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%s</TT
></TD
><TD
>Process start time stamp</TD
><TD
>no</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%v</TT
></TD
><TD
>Virtual transaction ID (backendID/localXID)</TD
><TD
>no</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%x</TT
></TD
><TD
>Transaction ID (0 if none is assigned)</TD
><TD
>no</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%q</TT
></TD
><TD
>Produces no output, but tells non-session
             processes to stop at this point in the string; ignored by
             session processes</TD
><TD
>no</TD
></TR
><TR
><TD
><TT
CLASS="LITERAL"
>%%</TT
></TD
><TD
>Literal <TT
CLASS="LITERAL"
>%</TT
></TD
><TD
>no</TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
>

         The <TT
CLASS="LITERAL"
>%c</TT
> escape prints a quasi-unique session identifier,
         consisting of two 4-byte hexadecimal numbers (without leading zeros)
         separated by a dot.  The numbers are the process start time and the
         process ID, so <TT
CLASS="LITERAL"
>%c</TT
> can also be used as a space saving way
         of printing those items.  For example, to generate the session
         identifier from <TT
CLASS="LITERAL"
>pg_stat_activity</TT
>, use this query:
</P><PRE
CLASS="PROGRAMLISTING"
>SELECT to_hex(EXTRACT(EPOCH FROM backend_start)::integer) || '.' ||
       to_hex(pid)
FROM pg_stat_activity;</PRE
><P>

       </P
><DIV
CLASS="TIP"
><BLOCKQUOTE
CLASS="TIP"
><P
><B
>Tip: </B
>         If you set a nonempty value for <TT
CLASS="VARNAME"
>log_line_prefix</TT
>,
         you should usually make its last character be a space, to provide
         visual separation from the rest of the log line.  A punctuation
         character can be used too.
        </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="TIP"
><BLOCKQUOTE
CLASS="TIP"
><P
><B
>Tip: </B
>         <SPAN
CLASS="APPLICATION"
>Syslog</SPAN
> produces its own
         time stamp and process ID information, so you probably do not want to
         include those escapes if you are logging to <SPAN
CLASS="APPLICATION"
>syslog</SPAN
>.
        </P
></BLOCKQUOTE
></DIV
></DD
><DT
><A
NAME="GUC-LOG-LOCK-WAITS"
></A
><TT
CLASS="VARNAME"
>log_lock_waits</TT
> (<TT
CLASS="TYPE"
>boolean</TT
>)</DT
><DD
><P
>        Controls whether a log message is produced when a session waits
        longer than <A
HREF="runtime-config-locks.html#GUC-DEADLOCK-TIMEOUT"
>deadlock_timeout</A
> to acquire a
        lock.  This is useful in determining if lock waits are causing
        poor performance.  The default is <TT
CLASS="LITERAL"
>off</TT
>.
        Only superusers can change this setting.
       </P
></DD
><DT
><A
NAME="GUC-LOG-STATEMENT"
></A
><TT
CLASS="VARNAME"
>log_statement</TT
> (<TT
CLASS="TYPE"
>enum</TT
>)</DT
><DD
><P
>        Controls which SQL statements are logged. Valid values are
        <TT
CLASS="LITERAL"
>none</TT
> (off), <TT
CLASS="LITERAL"
>ddl</TT
>, <TT
CLASS="LITERAL"
>mod</TT
>, and
        <TT
CLASS="LITERAL"
>all</TT
> (all statements). <TT
CLASS="LITERAL"
>ddl</TT
> logs all data definition
        statements, such as <TT
CLASS="COMMAND"
>CREATE</TT
>, <TT
CLASS="COMMAND"
>ALTER</TT
>, and
        <TT
CLASS="COMMAND"
>DROP</TT
> statements. <TT
CLASS="LITERAL"
>mod</TT
> logs all
        <TT
CLASS="LITERAL"
>ddl</TT
> statements, plus data-modifying statements
        such as <TT
CLASS="COMMAND"
>INSERT</TT
>,
        <TT
CLASS="COMMAND"
>UPDATE</TT
>, <TT
CLASS="COMMAND"
>DELETE</TT
>, <TT
CLASS="COMMAND"
>TRUNCATE</TT
>,
        and <TT
CLASS="COMMAND"
>COPY FROM</TT
>.
        <TT
CLASS="COMMAND"
>PREPARE</TT
>, <TT
CLASS="COMMAND"
>EXECUTE</TT
>, and
        <TT
CLASS="COMMAND"
>EXPLAIN ANALYZE</TT
> statements are also logged if their
        contained command is of an appropriate type.  For clients using
        extended query protocol, logging occurs when an Execute message
        is received, and values of the Bind parameters are included
        (with any embedded single-quote marks doubled).
       </P
><P
>        The default is <TT
CLASS="LITERAL"
>none</TT
>. Only superusers can change this
        setting.
       </P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>         Statements that contain simple syntax errors are not logged
         even by the <TT
CLASS="VARNAME"
>log_statement</TT
> = <TT
CLASS="LITERAL"
>all</TT
> setting,
         because the log message is emitted only after basic parsing has
         been done to determine the statement type.  In the case of extended
         query protocol, this setting likewise does not log statements that
         fail before the Execute phase (i.e., during parse analysis or
         planning).  Set <TT
CLASS="VARNAME"
>log_min_error_statement</TT
> to
         <TT
CLASS="LITERAL"
>ERROR</TT
> (or lower) to log such statements.
        </P
></BLOCKQUOTE
></DIV
></DD
><DT
><A
NAME="GUC-LOG-TEMP-FILES"
></A
><TT
CLASS="VARNAME"
>log_temp_files</TT
> (<TT
CLASS="TYPE"
>integer</TT
>)</DT
><DD
><P
>        Controls logging of temporary file names and sizes.
        Temporary files can be
        created for sorts, hashes, and temporary query results.
        A log entry is made for each temporary file when it is deleted.
        A value of zero logs all temporary file information, while positive
        values log only files whose size is greater than or equal to
        the specified number of kilobytes.  The
        default setting is -1, which disables such logging.
        Only superusers can change this setting.
       </P
></DD
><DT
><A
NAME="GUC-LOG-TIMEZONE"
></A
><TT
CLASS="VARNAME"
>log_timezone</TT
> (<TT
CLASS="TYPE"
>string</TT
>)</DT
><DD
><P
>        Sets the time zone used for timestamps written in the server log.
        Unlike <A
HREF="runtime-config-client.html#GUC-TIMEZONE"
>TimeZone</A
>, this value is cluster-wide,
        so that all sessions will report timestamps consistently.
        The built-in default is <TT
CLASS="LITERAL"
>GMT</TT
>, but that is typically
        overridden in <TT
CLASS="FILENAME"
>postgresql.conf</TT
>; <SPAN
CLASS="APPLICATION"
>initdb</SPAN
>
        will install a setting there corresponding to its system environment.
        See <A
HREF="datatype-datetime.html#DATATYPE-TIMEZONES"
>Section 8.5.3</A
> for more information.
        This parameter can only be set in the <TT
CLASS="FILENAME"
>postgresql.conf</TT
>
        file or on the server command line.
       </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="RUNTIME-CONFIG-LOGGING-CSVLOG"
>18.8.4. Using CSV-Format Log Output</A
></H2
><P
>        Including <TT
CLASS="LITERAL"
>csvlog</TT
> in the <TT
CLASS="VARNAME"
>log_destination</TT
> list
        provides a convenient way to import log files into a database table.
        This option emits log lines in comma-separated-values
        (<ACRONYM
CLASS="ACRONYM"
>CSV</ACRONYM
>) format,
        with these columns:
        time stamp with milliseconds,
        user name,
        database name,
        process ID,
        client host:port number,
        session ID,
        per-session line number,
        command tag,
        session start time,
        virtual transaction ID,
        regular transaction ID,
        error severity,
        SQLSTATE code,
        error message,
        error message detail,
        hint,
        internal query that led to the error (if any),
        character count of the error position therein,
        error context,
        user query that led to the error (if any and enabled by
        <TT
CLASS="VARNAME"
>log_min_error_statement</TT
>),
        character count of the error position therein,
        location of the error in the PostgreSQL source code
        (if <TT
CLASS="VARNAME"
>log_error_verbosity</TT
> is set to <TT
CLASS="LITERAL"
>verbose</TT
>),
        and application name.
        Here is a sample table definition for storing CSV-format log output:

</P><PRE
CLASS="PROGRAMLISTING"
>CREATE TABLE postgres_log
(
  log_time timestamp(3) with time zone,
  user_name text,
  database_name text,
  process_id integer,
  connection_from text,
  session_id text,
  session_line_num bigint,
  command_tag text,
  session_start_time timestamp with time zone,
  virtual_transaction_id text,
  transaction_id bigint,
  error_severity text,
  sql_state_code text,
  message text,
  detail text,
  hint text,
  internal_query text,
  internal_query_pos integer,
  context text,
  query text,
  query_pos integer,
  location text,
  application_name text,
  PRIMARY KEY (session_id, session_line_num)
);</PRE
><P>
       </P
><P
>        To import a log file into this table, use the <TT
CLASS="COMMAND"
>COPY FROM</TT
>
        command:

</P><PRE
CLASS="PROGRAMLISTING"
>COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;</PRE
><P>
       </P
><P
>       There are a few things you need to do to simplify importing CSV log
       files:

       <P
></P
></P><OL
TYPE="1"
><LI
><P
>            Set <TT
CLASS="VARNAME"
>log_filename</TT
> and
            <TT
CLASS="VARNAME"
>log_rotation_age</TT
> to provide a consistent,
            predictable naming scheme for your log files.  This lets you
            predict what the file name will be and know when an individual log
            file is complete and therefore ready to be imported.
         </P
></LI
><LI
><P
>            Set <TT
CLASS="VARNAME"
>log_rotation_size</TT
> to 0 to disable
            size-based log rotation, as it makes the log file name difficult
            to predict.
           </P
></LI
><LI
><P
>           Set <TT
CLASS="VARNAME"
>log_truncate_on_rotation</TT
> to <TT
CLASS="LITERAL"
>on</TT
> so
           that old log data isn't mixed with the new in the same file.
          </P
></LI
><LI
><P
>           The table definition above includes a primary key specification.
           This is useful to protect against accidentally importing the same
           information twice.  The <TT
CLASS="COMMAND"
>COPY</TT
> command commits all of the
           data it imports at one time, so any error will cause the entire
           import to fail.  If you import a partial log file and later import
           the file again when it is complete, the primary key violation will
           cause the import to fail.  Wait until the log is complete and
           closed before importing.  This procedure will also protect against
           accidentally importing a partial line that hasn't been completely
           written, which would also cause <TT
CLASS="COMMAND"
>COPY</TT
> to fail.
          </P
></LI
></OL
><P>
      </P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="runtime-config-query.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="runtime-config-statistics.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Query Planning</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="runtime-config.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Run-time Statistics</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>

Youez - 2016 - github.com/yon3zu
LinuXploit