Log Dateien - Wo sind die?

Hallo PG User

Ich suche die Log Dateien von PG. Unter /var/log/postgres kann ich sie nicht finden bzw. da ist überhaupt gar nichts mit postgres. Also mich Interessieren die Log Dateien wo drin steht wann sich welcher Benutzer angemeldet hat und was dieser Benutzer gemacht hat.

Kommt auf die Distibution und die Einstellungen in der postgresql.conf an. Hier ist es z.B.:

/var/log/postgresql/postgresql-8.1-main.log


mit postgres. Also mich Interessieren die Log Dateien wo drin steht wann sich welcher Benutzer angemeldet hat und was dieser Benutzer gemacht hat.

Den Inhalt kannst Du auch wieder in der postgresql.conf einstellen. Da gibt es Variablen wie log_line_prefix, log_statement, log_min_duration_statement etc.

Die postgresql.conf ist einerseits gut kommentiert, andererseits existiert auch http://www.powerpostgresql.com/Downloads/annotated_conf_80.html

Andreas

OK vielen Dank. Die postgresql.conf hab ich gefunden. Der Abschnitt mit dem Logging auch. Bei mir sieht der nach der Änderung so aus. Ich kann im Data Verzeichnis kein Verzeichnis mit dem namen pg_log finden auch im /var/log nicht. Ich habe openSuSE 10.2.

#---------------------------------------------------------------------------
# ERROR REPORTING AND LOGGING
#---------------------------------------------------------------------------

# - Where to Log -

log_destination = 'stderr'		# Valid values are combinations of 
					# stderr, syslog and eventlog, 
					# depending on platform.

# This is used when logging to stderr:
#redirect_stderr = off			# Enable capturing of stderr into log 
					# files
					# (change requires restart)

# These are only used if redirect_stderr is on:
log_directory = 'pg_log'		# Directory where log files are written
					# Can be absolute or relative to PGDATA
#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # Log file name pattern.
					# Can include strftime() escapes
#log_truncate_on_rotation = off # If on, any existing log file of the same 
					# name as the new log file will be
					# truncated rather than appended to. But
					# such truncation only occurs on
					# time-driven rotation, not on restarts
					# or size-driven rotation. Default is
					# off, meaning append to existing files
					# in all cases.
#log_rotation_age = 1d			# Automatic rotation of logfiles will 
					# happen after that time.  0 to 
					# disable.
#log_rotation_size = 10MB		# Automatic rotation of logfiles will 
					# happen after that much log
					# output.  0 to disable.

# These are relevant when logging to syslog:
#syslog_facility = 'LOCAL0'
#syslog_ident = 'postgres'


# - When to Log -

#client_min_messages = notice		# Values, in order of decreasing detail:
					#   debug5
					#   debug4
					#   debug3
					#   debug2
					#   debug1
					#   log
					#   notice
					#   warning
					#   error

#log_min_messages = notice		# Values, in order of decreasing detail:
					#   debug5
					#   debug4
					#   debug3
					#   debug2
					#   debug1
					#   info
					#   notice
					#   warning
					#   error
					#   log
					#   fatal
					#   panic

#log_error_verbosity = default		# terse, default, or verbose messages

#log_min_error_statement = error	# Values in order of increasing severity:
				 	#   debug5
					#   debug4
					#   debug3
					#   debug2
					#   debug1
				 	#   info
					#   notice
					#   warning
					#   error
					#   fatal
					#   panic (effectively off)

#log_min_duration_statement = -1	# -1 is disabled, 0 logs all statements
					# and their durations.

#silent_mode = off			# DO NOT USE without syslog or 
					# redirect_stderr
					# (change requires restart)

# - What to Log -

#debug_print_parse = off
#debug_print_rewritten = off
#debug_print_plan = off
#debug_pretty_print = off
log_connections = on
#log_disconnections = off
#log_duration = off
#log_line_prefix = ''			# Special values:
					#   %u = user name
					#   %d = database name
					#   %r = remote host and port
					#   %h = remote host
					#   %p = PID
					#   %t = timestamp (no milliseconds)
					#   %m = timestamp with milliseconds
					#   %i = command tag
					#   %c = session id
					#   %l = session line number
					#   %s = session start timestamp
					#   %x = transaction id
					#   %q = stop here in non-session 
					#        processes
					#   %% = '%'
					# e.g. '<%u%%%d> '
#log_statement = 'none'			# none, ddl, mod, all
log_hostname = on

So ich hab das Problem gelöst. Für alle die das gleiche wollen: Jetzt steht in der Log: Zeit, Benutzername, Datenbank der Aktion. Die Logs werden täglich in /var/pg_log abgelegt. pg_log hat die Rechte 740

#---------------------------------------------------------------------------
# ERROR REPORTING AND LOGGING
#---------------------------------------------------------------------------

# - Where to Log -

log_destination = 'stderr'		# Valid values are combinations of 
					# stderr, syslog and eventlog, 
					# depending on platform.

# This is used when logging to stderr:
redirect_stderr = on			# Enable capturing of stderr into log 
					# files
					# (change requires restart)

# These are only used if redirect_stderr is on:
log_directory = '/var/log/pg_log'		# Directory where log files are written
					# Can be absolute or relative to PGDATA
log_filename = 'postgresql-%d-%m-%Y.log' # Log file name pattern.
					# Can include strftime() escapes
#log_truncate_on_rotation = off # If on, any existing log file of the same 
					# name as the new log file will be
					# truncated rather than appended to. But
					# such truncation only occurs on
					# time-driven rotation, not on restarts
					# or size-driven rotation. Default is
					# off, meaning append to existing files
					# in all cases.
log_rotation_age = 1d			# Automatic rotation of logfiles will 
					# happen after that time.  0 to 
					# disable.
#log_rotation_size = 10MB		# Automatic rotation of logfiles will 
					# happen after that much log
					# output.  0 to disable.

# These are relevant when logging to syslog:
#syslog_facility = 'LOCAL0'
#syslog_ident = 'postgres'


# - When to Log -

#client_min_messages = notice		# Values, in order of decreasing detail:
					#   debug5
					#   debug4
					#   debug3
					#   debug2
					#   debug1
					#   log
					#   notice
					#   warning
					#   error

#log_min_messages = notice		# Values, in order of decreasing detail:
					#   debug5
					#   debug4
					#   debug3
					#   debug2
					#   debug1
					#   info
					#   notice
					#   warning
					#   error
					#   log
					#   fatal
					#   panic

#log_error_verbosity = default		# terse, default, or verbose messages

#log_min_error_statement = error	# Values in order of increasing severity:
				 	#   debug5
					#   debug4
					#   debug3
					#   debug2
					#   debug1
				 	#   info
					#   notice
					#   warning
					#   error
					#   fatal
					#   panic (effectively off)

#log_min_duration_statement = -1	# -1 is disabled, 0 logs all statements
					# and their durations.

#silent_mode = off			# DO NOT USE without syslog or 
					# redirect_stderr
					# (change requires restart)

# - What to Log -

#debug_print_parse = off
#debug_print_rewritten = off
#debug_print_plan = off
#debug_pretty_print = off
log_connections = on
#log_disconnections = off
#log_duration = off
log_line_prefix = '%t %u %d '	# Special values:
					#   %u = user name
					#   %d = database name
					#   %r = remote host and port
					#   %h = remote host
					#   %p = PID
					#   %t = timestamp (no milliseconds)
					#   %m = timestamp with milliseconds
					#   %i = command tag
					#   %c = session id
					#   %l = session line number
					#   %s = session start timestamp
					#   %x = transaction id
					#   %q = stop here in non-session 
					#        processes
					#   %% = '%'
					# e.g. '<%u%%%d> '
log_statement = 'mod'			# none, ddl, mod, all
log_hostname = on