Document the translations from Postgres message severity levels to

syslog and eventlog severity levels, per suggestion from Josh Drake.
Also, some wordsmithing for the csvlog documentation.
This commit is contained in:
Tom Lane 2007-09-22 19:10:44 +00:00
parent f316222930
commit 90c156f0d1
1 changed files with 129 additions and 121 deletions

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.144 2007/09/10 02:01:19 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.145 2007/09/22 19:10:44 tgl Exp $ -->
<chapter Id="runtime-config"> <chapter Id="runtime-config">
<title>Server Configuration</title> <title>Server Configuration</title>
@ -2262,11 +2262,13 @@ SELECT * FROM parent WHERE key = 2400;
This parameter can only be set in the <filename>postgresql.conf</> This parameter can only be set in the <filename>postgresql.conf</>
file or on the server command line. file or on the server command line.
</para> </para>
<para> If <varname>log_destination</> is set to <systemitem>csvlog</systemitem>, <para>
the log is output as comma seperated values. The format is: If <systemitem>csvlog</> is included in <varname>log_destination</>,
timestamp with milliseconds, username, database name, session id, host:port number, log entries are output in <quote>comma separated
process id, per process line number, command tag, session start time, transaction id, value</> format, which is convenient for loading them into programs.
error severity, SQL state code, statement/error message. See <xref linkend="runtime-config-logging-csvlog"> for details.
<varname>logging_collector</varname> must be enabled to generate
CSV-format log output.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -2279,16 +2281,13 @@ SELECT * FROM parent WHERE key = 2400;
<listitem> <listitem>
<para> <para>
This parameter allows messages sent to <application>stderr</>, This parameter allows messages sent to <application>stderr</>,
and CSV logs, to be and CSV-format log output, to be
captured and redirected into log files. captured and redirected into log files.
This method, in combination with logging to <application>stderr</>, This approach is often more useful than
is often more useful than
logging to <application>syslog</>, since some types of messages logging to <application>syslog</>, since some types of messages
might not appear in <application>syslog</> output (a common example might not appear in <application>syslog</> output (a common example
is dynamic-linker failure messages). is dynamic-linker failure messages).
This parameter can only be set at server start. This parameter can only be set at server start.
<varname>logging_collector</varname> must be enabled to generate
CSV logs.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -2334,12 +2333,13 @@ SELECT * FROM parent WHERE key = 2400;
file or on the server command line. file or on the server command line.
</para> </para>
<para> <para>
If <varname>log_destination</> is set to <systemitem>csvlog</>, If CSV-format output is enabled in <varname>log_destination</>,
<literal>.csv</> will be appended to the timestamped <literal>.csv</> will be appended to the timestamped
<varname>log_filename</> to create the final log file name. log file name to create the file name for CSV-format output.
(If log_filename ends in <literal>.log</>, the suffix is overwritten.) (If <varname>log_filename</> ends in <literal>.log</>, the suffix is
In the case of the example above, the replaced instead.)
file name will be <literal>server_log.1093827753.csv</literal> In the case of the example above, the CSV
file name will be <literal>server_log.1093827753.csv</literal>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -2617,88 +2617,92 @@ SELECT * FROM parent WHERE key = 2400;
</variablelist> </variablelist>
<para> <para>
Here is a list of the various message severity levels used in <xref linkend="runtime-config-severity-levels"> explains the message
these settings: severity levels used by <productname>PostgreSQL</>. If logging output
<variablelist> is sent to <systemitem>syslog</systemitem> or Windows'
<varlistentry> <systemitem>eventlog</systemitem>, the severity levels are translated
<term><literal>DEBUG[1-5]</literal></term> as shown in the table.
<listitem> </para>
<para>
Provides information for use by developers.
</para>
</listitem>
</varlistentry>
<varlistentry> <table id="runtime-config-severity-levels">
<term><literal>INFO</literal></term> <title>Message severity levels</title>
<listitem> <tgroup cols="4">
<para> <thead>
Provides information implicitly requested by the user, <row>
e.g., during <command>VACUUM VERBOSE</>. <entry>Severity</entry>
</para> <entry>Usage</entry>
</listitem> <entry><systemitem>syslog</></entry>
</varlistentry> <entry><systemitem>eventlog</></entry>
</row>
</thead>
<varlistentry> <tbody>
<term><literal>NOTICE</literal></term> <row>
<listitem> <entry><literal>DEBUG1..DEBUG5</></entry>
<para> <entry>Provides successively-more-detailed information for use by
Provides information that might be helpful to users, e.g., developers.</entry>
truncation of long identifiers and the creation of indexes as part <entry><literal>DEBUG</></entry>
of primary keys. <entry><literal>INFORMATION</></entry>
</para> </row>
</listitem>
</varlistentry>
<varlistentry> <row>
<term><literal>WARNING</literal></term> <entry><literal>INFO</></entry>
<listitem> <entry>Provides information implicitly requested by the user,
<para> e.g., output from <command>VACUUM VERBOSE</>.</entry>
Provides warnings to the user, e.g., <command>COMMIT</> <entry><literal>INFO</></entry>
outside a transaction block. <entry><literal>INFORMATION</></entry>
</para> </row>
</listitem>
</varlistentry>
<varlistentry> <row>
<term><literal>ERROR</literal></term> <entry><literal>NOTICE</></entry>
<listitem> <entry>Provides information that might be helpful to users, e.g.,
<para> notice of truncation of long identifiers.</entry>
Reports an error that caused the current command to abort. <entry><literal>NOTICE</></entry>
</para> <entry><literal>INFORMATION</></entry>
</listitem> </row>
</varlistentry>
<varlistentry> <row>
<term><literal>LOG</literal></term> <entry><literal>WARNING</></entry>
<listitem> <entry>Provides warnings of likely problems, e.g., <command>COMMIT</>
<para> outside a transaction block.</entry>
Reports information of interest to administrators, e.g., <entry><literal>NOTICE</></entry>
checkpoint activity. <entry><literal>WARNING</></entry>
</para> </row>
</listitem>
</varlistentry>
<varlistentry> <row>
<term><literal>FATAL</literal></term> <entry><literal>ERROR</></entry>
<listitem> <entry>Reports an error that caused the current command to
<para> abort.</entry>
Reports an error that caused the current session to abort. <entry><literal>WARNING</></entry>
</para> <entry><literal>ERROR</></entry>
</listitem> </row>
</varlistentry>
<varlistentry> <row>
<term><literal>PANIC</literal></term> <entry><literal>LOG</></entry>
<listitem> <entry>Reports information of interest to administrators, e.g.,
<para> checkpoint activity.</entry>
Reports an error that caused all sessions to abort. <entry><literal>INFO</></entry>
</para> <entry><literal>INFORMATION</></entry>
</listitem> </row>
</varlistentry>
</variablelist> <row>
</para> <entry><literal>FATAL</></entry>
<entry>Reports an error that caused the current session to
abort.</entry>
<entry><literal>ERR</></entry>
<entry><literal>ERROR</></entry>
</row>
<row>
<entry><literal>PANIC</></entry>
<entry>Reports an error that caused all database sessions to abort.</entry>
<entry><literal>CRIT</></entry>
<entry><literal>ERROR</></entry>
</row>
</tbody>
</tgroup>
</table>
</sect2> </sect2>
<sect2 id="runtime-config-logging-what"> <sect2 id="runtime-config-logging-what">
@ -3082,27 +3086,32 @@ SELECT * FROM parent WHERE key = 2400;
</variablelist> </variablelist>
</sect2> </sect2>
<sect2 id="runtime-config-logging-csvlog"> <sect2 id="runtime-config-logging-csvlog">
<title>Using the csvlog</title> <title>Using CSV-Format Log Output</title>
<para> <para>
Including <literal>csvlog</> in the <varname>log_destination</> list Including <literal>csvlog</> in the <varname>log_destination</> list
provides a convenient way to import log files into a database table. provides a convenient way to import log files into a database table.
Here is a sample table definition for storing csvlog output: This option emits log lines in comma-separated-value format,
with these columns: timestamp with milliseconds, username, database
name, session id, host:port number, process id, per-process line
number, command tag, session start time, transaction id, error
severity, SQL state code, statement/error message.
Here is a sample table definition for storing CSV-format log output:
</para> </para>
<programlisting> <programlisting>
CREATE TABLE postgres_log CREATE TABLE postgres_log
( (
log_time timestamp, log_time timestamp with time zone,
username text, username text,
database_name text, database_name text,
sessionid text not null, sessionid text,
connection_from text, connection_from text,
process_id text, process_id integer,
process_line_num int not null, process_line_num bigint,
command_tag text, command_tag text,
session_start_time timestamp, session_start_time timestamp with time zone,
transaction_id int, transaction_id bigint,
error_severity text, error_severity text,
sql_state_code text, sql_state_code text,
statement text, statement text,
@ -3112,7 +3121,8 @@ CREATE TABLE postgres_log
<para> <para>
In order to import into this table, use the COPY FROM command: To import a log file into this table, use the <command>COPY FROM</>
command:
</para> </para>
<programlisting> <programlisting>
@ -3120,18 +3130,17 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
</programlisting> </programlisting>
<para> <para>
There are a few things you need to import csvlog files easily and There are a few things you need to do to simplify importing CSV log
automatically: files easily and automatically:
<orderedlist> <orderedlist>
<listitem> <listitem>
<para> <para>
Use a consistant, predictable naming scheme for your log files Set <varname>log_filename</varname> and
with <varname>log_filename</varname>. This lets you predict what <varname>log_rotation_age</> to provide a consistent,
the file name will be when it is ready to be imported. predictable naming scheme for your log files. This lets you
guess what predict what the file name will be and know when an individual log
the file name will be and know when an individual log file is file is complete and therefore ready to be imported.
complete and therefore ready to be imported.
</para> </para>
</listitem> </listitem>
@ -3145,24 +3154,23 @@ guess what
<listitem> <listitem>
<para> <para>
Set <varname>log_truncate_on_rotate</varname> = on so that old Set <varname>log_truncate_on_rotation</varname> to <literal>on</> so
log data isn't mixed with the new in the same file. that old log data isn't mixed with the new in the same file.
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
The example above includes a useful primary key on the log The table definition above includes a primary key specification.
file data, which will protect against accidentally importing This is useful to protect against accidentally importing the same
the same information twice. The COPY command commits all of information twice. The <command>COPY</> command commits all of the
the data it imports at one time, and any single error will data it imports at one time, so any error will cause the entire
cause the entire import to fail. import to fail. If you import a partial log file and later import
If you import a partial log file and later import the file again the file again when it is complete, the primary key violation will
when it is complete, the primary key violation will cause the cause the import to fail. Wait until the log is complete and
import to fail. Wait until the log is complete and closed before closed before importing. This procedure will also protect against
import. This will also protect against accidently importing a accidentally importing a partial line that hasn't been completely
partial line that hasn't been completely written, which would written, which would also cause <command>COPY</> to fail.
also cause the COPY to fail.
</para> </para>
</listitem> </listitem>
</orderedlist> </orderedlist>