??????? PostgreSQL ?????
???????????????????????? vanilla PostgreSQL 9.4 ?????????????????????? postgresql.conf????????Linux ???е??????????????????????? /etc ????????е????Σ??????????????? Centos 7 ???????? /var/lib/pgsql ???????????
????root@localhost ~]# vi /var/lib/pgsql/9.4/data/postgresql.conf
????...
????#------------------------------------------------------------------------------
????# ERROR REPORTING AND LOGGING
????#------------------------------------------------------------------------------
????# - Where to Log -
????log_destination = 'stderr'     
????# Valid values are combinations of
????# stderr?? csvlog?? syslog?? and eventlog??
????# depending on platform. csvlog
????# requires logging_collector to be on.
????# This is used when logging to stderr:
????logging_collector = on         
????# Enable capturing of stderr and csvlog
????# into log files. Required to be on for
????# csvlogs.
????# (change requires restart)
????# These are only used if logging_collector is on:
????log_directory = 'pg_log'      
????# directory where log files are written??
????# can be absolute or relative to PGDATA
????log_filename = 'postgresql-%a.log'    # log file name pattern??
????# can include strftime() escapes
????# log_file_mode = 0600           .
????# creation mode for log files??
????# begin with 0 to use octal notation
????log_truncate_on_rotation = on   # If on?? an existing log file with 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 disables.
????log_rotation_size = 0           # Automatic rotation of logfiles will happen after that much log output. 0 disables.
????# These are relevant when logging to syslog:
????#syslog_facility = 'LOCAL0'
????#syslog_ident = 'postgres'
????# This is only relevant when logging to eventlog (win32):
????#event_source = 'PostgreSQL'
????# - 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 = warning     # values in order of decreasing detail:
????# debug5
????# debug4
????# debug3
????# debug2
????# debug1
????# info
????# notice
????# warning
????# error
????# log
????# fatal
????# panic
????#log_min_error_statement = error    # values in order of decreasing detail:
????# debug5
????# debug4
????# debug3
????# debug2
????# debug1
????# info
????# notice
????# warning
????# error
????# log
????# fatal
????# panic (effectively off)
????#log_min_duration_statement = -1     # -1 is disabled?? 0 logs all statements
????# and their durations?? > 0 logs only
????# statements running at least this number
????# of milliseconds
????# - What to Log
????#debug_print_parse = off
????#debug_print_rewritten = off
????#debug_print_plan = off
????#debug_pretty_print = on
????#log_checkpoints = off
????#log_connections = off
????#log_disconnections = off
????#log_duration = off
????#log_error_verbosity = default   
????# terse?? default?? or verbose messages
????#log_hostname = off
????log_line_prefix = '< %m >'          # special values:
????# %a = application name
????# %u = user name
????# %d = database name
????# %r = remote host and port
????# %h = remote host
????# %p = process ID
????# %t = timestamp without milliseconds
????# %m = timestamp with milliseconds
????# %i = command tag
????# %e = SQL state
????# %c = session ID
????# %l = session line number
????# %s = session start timestamp
????# %v = virtual transaction ID
????# %x = transaction ID (0 if none)
????# %q = stop here in non-session
????# processes
????# %% = '%'
????# e.g. '<%u%%%d> '
????#log_lock_waits = off               # log lock waits >= deadlock_timeout
????#log_statement = 'none'             # none?? ddl?? mod?? all
????#log_temp_files = -1                # log temporary files equal or larger
????# than the specified size in kilobytes;5# -1 disables?? 0 logs all temp files5
????log_timezone = 'Australia/ACT'
??????????????????????????????????????????????????????????????? pglog??logdirectory ???????? /var/lib/pgsql/9.4/data/ ?μ??????????????????? postgresql ?????logfilename???????????????????Σ?logrotationage ?????????????????????????????loglineprefix????????????????????? logline_prefix ???????????????????????????
?????? /var/lib/pgsql/9.4/data/pg_log ??????????????Щ?????
????[root@localhost ~]# ls -l /var/lib/pgsql/9.4/data/pg_log
????total 20
????-rw-------. 1 postgres postgres 1212 May 1 20:11 postgresql-Fri.log
????-rw-------. 1 postgres postgres 243 Feb 9 21:49 postgresql-Mon.log
????-rw-------. 1 postgres postgres 1138 Feb 7 11:08 postgresql-Sat.log
????-rw-------. 1 postgres postgres 1203 Feb 26 21:32 postgresql-Thu.log
????-rw-------. 1 postgres postgres 326 Feb 10 01:20 postgresql-Tue.log
??????????????????????????????????????????????????????? postgresql.conf ???? log_filename ??????
??????????????????????????????????儷???
????[root@localhost ~]# cat /var/lib/pgsql/9.4/data/pg_log/postgresql-Fri.log
????...
????< 2015-02-27 01:21:27.020 EST >LOG: received fast shutdown request
????< 2015-02-27 01:21:27.025 EST >LOG: aborting any active transactions
????< 2015-02-27 01:21:27.026 EST >LOG: autovacuum launcher shutting down
????< 2015-02-27 01:21:27.036 EST >LOG: shutting down
????< 2015-02-27 01:21:27.211 EST >LOG: database system is shut down
?????鼯???????
??????? imfile ??????
???????????????????????????????????????????????????????????????????????????????????????????????????????μ?????????????β?????????????????з????????? /etc/rsyslog.d/ ????????μ?????????????????????????????????????£?
????$ModLoad imfile
????$InputFilePollInterval 10
????$PrivDropToGroup adm
????# Input for FILE1
????$InputFileName /FILE1
????$InputFileTag APPNAME1
????$InputFileStateFile stat-APPNAME1 #this must be unique for each file being polled
????$InputFileSeverity info
????$InputFilePersistStateInterval 20000
????$InputRunFileMonitor
?????滻 FILE1 ?? APPNAME1 ???????????????????????rsyslog ????????????????????????С?
?????????????????? imuxsock
????????????? UNIX ?????????????????????????????? syslog ???????????????У?????????????????д??????????????????logger ?????????????????? UNIX ??????
??????????????? I/O ???????????????????????????????????????????Ч???á???????????????????ж??д?С????????????? syslog ???????崵?????????????У???????????????????
????rsyslog ???????? /dev/log ??????ж???????????????????????????? imuxsock ??????? ????????
????$ModLoad imuxsock
????UDP ????? imupd
?????Щ??ó?????? UDP ????????????????????????????????????????????? syslog Э?顣??? syslog ????????????Щ??????????????????ò?????????????????????????????????????????????????????????????????С?
??????????????????? rsyslog ??? UDP ??????????? 514 ?? syslog ?????
????$ModLoad imudp
????$UDPServerRun 514
?????? logrotate ???????
?????????????????????????????????鵵???????????????????????????????????????t?????????????????????????
????logrotate ?????????????????????????????????????????????????????????????????????????????????????????? logrotate ???????У?????????????????????????????????????????????????????????????鵵???????
?????? logrotate ?????????????μ????????????μ? inode???????? rsyslog ??????????????????????copytruncate ????????? logrotate ??????????????????????????????????е?????????????????????????????????Щ???????????????????????????? inode ????????????????????????????
????logrotate ??????????????????? /etc/logrotate.conf??????????????? /etc/logrotate.d/ ?????DigitalOcean ?????????? logrotate ???
?????????????????????
??????????к???????????????????????????á???????м????????????????????????ù?????????????????????????????????????е????????????? rsyslog ??????????????????????? rsyslog ???????Ч??
????pssh
???????????????????????????????е???????? ssh ?????? pssh ??????????????????????????????????????????????????? ssh ?????????????????????????????к?????????????????????????????????
????Puppet/Chef
????Puppet ?? Chef ?????????????????????????????簴??漲????????????????з?????????????????????????????????????????????????Puppet ?? Chef ?????Щ????????????????????????????????????ù?????????????? InfoWorld ???????????????
?????Щ????????Щ???? rsyslog ???????????????????? Loggly ?? Puppet ??????????????? rsyslog ????????????????????????
????node 'my_server_node.example.net' {
????# Send syslog events to Loggly
????class { 'loggly::rsyslog':
????customer_token => 'de7b5ccd-04de-4dc4-fbc9-501393600000'??
????}
????}
????Docker
????Docker ????????????????????????????????ж??????????????????????????????????????????????ZDNet ???????????????????????? Docker ???????????
?????????к????? Docker ???????????????????????????????????????????????????????????????????? sysllog ????????????е???????????? logspout??
?????????????????
??????????????????????Щ???????????????????????????????????????????????????????????????????????Щ??????? Loggly ?????y????????????? syslog ???????????ɡ???????? Loggly ???????????????????????????????????????