SlideShare a Scribd company logo
1 of 39
Syslog and Log files
Haiying Bao
June 15, 1999
Outline
• Log files
– What need to be logged
– Logging policies
– Finding log files
• Syslog: the system event logger
– how syslog works
– its configuration file
– the software that uses syslog
– debugging syslog
What to be logged?
• The accounting system
• The kernel
• Various utilities
– all produce data that need to be logged
– most of the data has a limited useful lifetime,
and needs to be summarized, compressed,
archived and eventually thrown away
Logging policies
• Throw away all data immediately
• Reset log files at periodic intervals
• Rotate log files, keeping data for a fixed
time
• Compress and archive to tape or other
permanent media
Which one to choose
• Depends on :
– how much disk space you have
– how security-conscious you are
• Whatever scheme you select, regular
maintenance of log files should be
automated using cron (chap 10, periodic process)
Throwing away log files
• not recommend
– security problems ( accounting data and log
files provide important evidence of break-ins)
– helpful for alerting you to hardware and
software problems.
• In general, keep one or two months
– in a real world, it may take one or two weeks
for SA to realize that site has been
compromised by a hacker and need to review
the logs
Throwing away (cont.)
• Most sites store each day’s log info on disk,
sometimes in a compressed format
• These daily files are kept for a specific
period of time and then deleted
• One common way to implement this policy
is called “rotation”
Rotating log files
• Keep backup files that are one day old, two
days old, and so on.
– logfile, logfile.1 , logfile.2, … logfile.7
• Each day rename the files to push older data
toward the end of the chain
– script to archive three days files
#! /bin/sh
cd /var/log
mv logfile.2 logfile.3
mv logfile.1 logfile.2
mv logfile logfile.1
cat /dev/null > logfile
Some daemons keep their log files open all the time,
this script can’t be used with them. To install a new
log file, you must either signal the daemon, or kill
and restart it.
#! /bin/sh
cd /var/log
mv logfile.2.Z logfile.3.Z
mv logfile.1.Z logfile.2.Z
mv logfile logfile.1
cat /dev/null > logfile
kill -signal pid
compress logfile.1
signal - appropriate signal for the program
writing the log file
pid - process id
Archiving log files
• Some sites must archive all accounting
data and log files as a matter of policy, to
provide data for a potential audit
• Log files should be first rotate on disk,
then written to tape or other permanent
media
– see chap 11, Backups
Finding log files
• To locate log files, read the system startup
scripts : /etc/rc* or /etc/init.d/*
– if logging is turned on when daemons are run
– where messages are sent
• Some programs handle logging via syslog
– check /etc/syslog.conf to find out where this
data goes
Finding log files
• Different operating systems put log files in
different places:
– /var/log/*
– /var/cron/log
– /usr/adm
– /var/adm …
• On linux, all the log files are in /var/log
directory.
Outline
• Log files
– What need to be logged
– Logging policies
– Finding log files
• Syslog: the system event logger
– how syslog works
– its configuration file
– debugging syslog
– the software that uses syslog
What is syslog
• A comprehensive logging system, used to
manage information generated by the
kernel and system utilities.
• Allow messages to be sorted by their
sources and importance, and routed to a
variety of destinations:
– log files, users’ terminals, or even other
machines.
Syslog: three parts
• Syslogd and /etc/syslog.conf
– the daemon that does the actual logging
– its configuration file
• openlog, syslog, closelog
– library routines that programs use to send data
to syslogd
• logger
– user-level command for submitting log entries
syslog-aware programs
Using syslog lib. Routines
write log entries to a special file
/dev/log
syslogd /etc/syslog.conf
reads consults
dispatches
Log
files
Users’s
terminals
Other
machines
/dev/klog
Configuring syslogd
• The configuration file /etc/syslog.conf
controls syslogd’s behavior.
• It is a text file with simple format, blank
lines and lines beginning with ‘#’ are
ignored.
– Selector <TAB> action
– eg. mail.info /var/log/maillog
Configuration file
selector
• Identify
– source -- the program (‘facility’) that is sending
a log message
– importance -- the messages’s severity level
– eg. mail.info /var/log/maillog
• Syntax
– facility.level
– facility names and severity levels must chosen
from a list of defined values
Configuration file
Facility names
Facility Programs that use it
kern the kernel
user User process, default if not specified
mail The mail system
daemon System daemons
auth Security and authorization related
commands
lpr the BSD line printer spooling system
news The Usenet news system
Configuration file
Facility names
Facility Programs that use it
uucp Reserved for UUCP
cron the cron daemon
mark Timestamps generated at regular intervals
local0-7 Eight flavors of local message
syslog syslog internal messages
authpriv Private or system authorization messages
ftp the ftp daemon, ftpd
* All facilities except “mark”
Configuration file
Facility names
• Timestamps can be used to log time at
regular intervals (by default, every 20
minutes), so you can figure out that your
machine crashed between 3:00 and 3:20 am,
not just “sometime last night”. This can be a
big help if debugging problems occur on a
regular basis.
Configuration file
severity level
Level Approximate meaning
emerg (panic) Panic situation
alert Urgent situation
crit Critical condition
err Other error conditions
warning Warning messages
notice Unusual things that may need
investigation
info Informational messages
debug For debugging
Configuration file
selector
• Can include multiple facilities separated with ‘,’
commas
– daemon,auth,mail.level action
• Multiple selector can be combined with ‘;’
– daemon.level1; mail.level2 action
• Selector are ‘|’ --ORed together, a message
matching any selector will be subject to the action.
• Can contain ‘*’ or ‘none’, meaning all or nothing.
Configuration file
selector
• Levels indicate the minimum importance that a
message must have in order to be logged
– mail.warning, would match all the messages
from mail system, at the minimum level of
warning
• Level of ‘none’ will excludes the listed facilities
regardless of what other selectors on the same line
may say.
– *.level1;mail.none action
• all the facilities, except mail, at the minimum level 1 will
subject to action
Configuration file
action
(Tells what to do with a message)
Action Meaning
filename Write message to a file on the
local machine
@hostname Forward message to the syslogd on
hostname
@ipaddress Forward message to the host at IP address
user1, user2,… Write message to users’ screens if they
are logged in
* Write message to all users logged in
Configuration file
action
• If a filename action used, the filename must be
absolute path. The file must exist, syslogd will not
create it.
– /var/log/messages
• If a hostname is used, it must be resolved via a
translation mechanism such as DNS or NIS
• While multiple facilities and levels are allowed in
a selector, multiple actions are not allowed.
Config file examples
# Small network or stand-alone syslog.conf file
# emergencies: tell everyone who is logged on
*.emerg *
# important messages
*.warning;daemon,auth.info /var/adm/messages
# printer errors
lpr.debug /var/adm/lpd-errs
# network client, typically forwards serious messages to
# a central logging machine
# emergencies: tell everyone who is logged on
*.emerg;user.none *
#important messages, forward to central logger
*.warning;lpr,local1.none @netloghost
daemon,auth.info @netloghost
# local stuff to central logger too
local0,local2,local7.debug @netloghost
# card syslogs to local1 - to boulder
local1.debug @boulder.colorado.edu
# printer errors, keep them local
lpr.debug /var/adm/lpd-errs
# sudo logs to local2 - keep a copy here
local2.info /var/adm/sudolog
Sample syslog output
Dec 27 02:45:00 x-wing netinfod [71]: cann’t lookup child
Dec 27 02:50:00 bruno ftpd [27876]: open of pid file
failed: not a directory
Dec 27 02:50:47 anchor vmunix: spurious VME interrupt
at processor level 5
Dec 27 02:52:17 bruno pingem[107]: moose.cs.colorado.edu
has not answered 34 times
Dec 27 02:55:33 bruno sendmail [28040] : host name/address
mismatch: 192.93.110.26 != bull.bull..fr
Syslog ‘s functions
• Liberate programmers from the tedious
mechanics of writing log files
• Put SA in control of logging
– before syslog, SA had no control over what info
was kept or where it was stored.
• Can centralize the logging for a network
system
Syslogd (cont.)
• A hangup signal (HUP, signal 1) cause
syslogd to close its log files, reread its
configuration file, and start logging again.
• If you modify the syslog.conf file, you must
HUP syslogd to make your changes take
effect.
– Kill -1 pid
Debugging syslog -- logger
• Useful for submitting log entries from shell
scripts
• Can also use it to test changes in syslogd’s
configuration file.
– For example..
Add line to syslog.conf:
local5.warning /tmp/test.log
verify it is working, run
logger -p local5.warning “test messages”
a line containing “test messages” should be written to /tmp/test.log
If this doesn’t happen:
forgot to create the test.log file
forgot to send syslogd a hangup signal
Software that uses syslog
Program Facility Levels Description
amd auth err-info NFS automounter
date auth notice Display and set date
ftpd daemon err-debug ftp daemon
gated daemon alert-info Routing daemon
gopher daemon err Internet info server
halt/reboot auth crit Shutdown programs
login/rlogind auth crit-info Login programs
lpd lpr err-info BSD line printer daemon
Software that uses syslog
Program Facility Levels Description
named daemon err-info Name sever (DNS)
passwd auth err Password setting
programs
sendmail mail debug-alert Mail transport system
rwho daemon err-notice romote who daemon
su auth crit, notice substitute UID prog.
sudo local2 notice, alert Limited su program
syslogd syslog, mark err-info internet errors,
timestamps
Using syslog in programs
• openlog ( ident, logopt, facility);
– messages are logged with the options specified
by logopt begin with the identification string
ident.
• Syslog ( priority, messge, parameters…);
– send message to syslogd, which logs it at the
sepecified priority level
• close ( );
/ * c program: syslog using openlog and closelog */
#include <syslog.h>
main ( )
{
openlog ( “SA-BOOK”, LOG_PID, LOG_USER);
syslog ( LOG_WARNING, “Testing …. “);
closelog ( );
}
On the host, this code produce the following log entry:
Dec 28 17:23:49 moet.colorado.edu SA-BOOK [84]: Testing...
Final words
• On linux, check following files:
– /etc/syslog.conf : syslog configuration file
– /etc/logrotate.conf : logging policy, rotate
– /etc/logrotate.d/*
– /var/log/* : log files
• try following commands to find out more...
– man logrotate
– man syslogd

More Related Content

Similar to Syslog and Log File Configuration Guide

Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logsJeremy Cook
 
10 Tips for AIX Security
10 Tips for AIX Security10 Tips for AIX Security
10 Tips for AIX SecurityHelpSystems
 
(ATS6-PLAT07) Managing AEP in an enterprise environment
(ATS6-PLAT07) Managing AEP in an enterprise environment(ATS6-PLAT07) Managing AEP in an enterprise environment
(ATS6-PLAT07) Managing AEP in an enterprise environmentBIOVIA
 
Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)Amin Astaneh
 
Introduction to System Calls
Introduction to System CallsIntroduction to System Calls
Introduction to System CallsVandana Salve
 
Automotive Grade Linux and systemd
Automotive Grade Linux and systemdAutomotive Grade Linux and systemd
Automotive Grade Linux and systemdAlison Chaiken
 
Advanced Operating Systems......Process Management
Advanced Operating Systems......Process ManagementAdvanced Operating Systems......Process Management
Advanced Operating Systems......Process ManagementVeejeya Kumbhar
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debuggingHao-Ran Liu
 
linux monitoring and performance tunning
linux monitoring and performance tunning linux monitoring and performance tunning
linux monitoring and performance tunning iman darabi
 
19-reliabilitytesting.ppt
19-reliabilitytesting.ppt19-reliabilitytesting.ppt
19-reliabilitytesting.pptAnilteaser
 
Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Chander Pandey
 
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
Prometheus - Intro, CNCF, TSDB,PromQL,GrafanaPrometheus - Intro, CNCF, TSDB,PromQL,Grafana
Prometheus - Intro, CNCF, TSDB,PromQL,GrafanaSridhar Kumar N
 
Вячеслав Кабак "Microsoft Sysinternals-Useful Utilities"
Вячеслав Кабак "Microsoft Sysinternals-Useful Utilities"Вячеслав Кабак "Microsoft Sysinternals-Useful Utilities"
Вячеслав Кабак "Microsoft Sysinternals-Useful Utilities"EPAM Systems
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logsJeremy Cook
 
Linux security quick reference guide
Linux security quick reference guideLinux security quick reference guide
Linux security quick reference guideCraig Cannon
 
A3Sec Advanced Deployment System
A3Sec Advanced Deployment SystemA3Sec Advanced Deployment System
A3Sec Advanced Deployment Systema3sec
 
Bca i-fundamental of computer-u-3-functions operating systems
Bca  i-fundamental of  computer-u-3-functions operating systemsBca  i-fundamental of  computer-u-3-functions operating systems
Bca i-fundamental of computer-u-3-functions operating systemsRai University
 

Similar to Syslog and Log File Configuration Guide (20)

Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logs
 
10 Tips for AIX Security
10 Tips for AIX Security10 Tips for AIX Security
10 Tips for AIX Security
 
(ATS6-PLAT07) Managing AEP in an enterprise environment
(ATS6-PLAT07) Managing AEP in an enterprise environment(ATS6-PLAT07) Managing AEP in an enterprise environment
(ATS6-PLAT07) Managing AEP in an enterprise environment
 
Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)
 
Introduction to System Calls
Introduction to System CallsIntroduction to System Calls
Introduction to System Calls
 
Automotive Grade Linux and systemd
Automotive Grade Linux and systemdAutomotive Grade Linux and systemd
Automotive Grade Linux and systemd
 
Advanced Operating Systems......Process Management
Advanced Operating Systems......Process ManagementAdvanced Operating Systems......Process Management
Advanced Operating Systems......Process Management
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
linux monitoring and performance tunning
linux monitoring and performance tunning linux monitoring and performance tunning
linux monitoring and performance tunning
 
19-reliabilitytesting.ppt
19-reliabilitytesting.ppt19-reliabilitytesting.ppt
19-reliabilitytesting.ppt
 
OS_lab_file.pdf
OS_lab_file.pdfOS_lab_file.pdf
OS_lab_file.pdf
 
Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01
 
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
Prometheus - Intro, CNCF, TSDB,PromQL,GrafanaPrometheus - Intro, CNCF, TSDB,PromQL,Grafana
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
 
Вячеслав Кабак "Microsoft Sysinternals-Useful Utilities"
Вячеслав Кабак "Microsoft Sysinternals-Useful Utilities"Вячеслав Кабак "Microsoft Sysinternals-Useful Utilities"
Вячеслав Кабак "Microsoft Sysinternals-Useful Utilities"
 
Os
OsOs
Os
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logs
 
Linux security quick reference guide
Linux security quick reference guideLinux security quick reference guide
Linux security quick reference guide
 
Lecture 5 process concept
Lecture 5   process conceptLecture 5   process concept
Lecture 5 process concept
 
A3Sec Advanced Deployment System
A3Sec Advanced Deployment SystemA3Sec Advanced Deployment System
A3Sec Advanced Deployment System
 
Bca i-fundamental of computer-u-3-functions operating systems
Bca  i-fundamental of  computer-u-3-functions operating systemsBca  i-fundamental of  computer-u-3-functions operating systems
Bca i-fundamental of computer-u-3-functions operating systems
 

Recently uploaded

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 

Recently uploaded (20)

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 

Syslog and Log File Configuration Guide

  • 1. Syslog and Log files Haiying Bao June 15, 1999
  • 2. Outline • Log files – What need to be logged – Logging policies – Finding log files • Syslog: the system event logger – how syslog works – its configuration file – the software that uses syslog – debugging syslog
  • 3. What to be logged? • The accounting system • The kernel • Various utilities – all produce data that need to be logged – most of the data has a limited useful lifetime, and needs to be summarized, compressed, archived and eventually thrown away
  • 4. Logging policies • Throw away all data immediately • Reset log files at periodic intervals • Rotate log files, keeping data for a fixed time • Compress and archive to tape or other permanent media
  • 5. Which one to choose • Depends on : – how much disk space you have – how security-conscious you are • Whatever scheme you select, regular maintenance of log files should be automated using cron (chap 10, periodic process)
  • 6. Throwing away log files • not recommend – security problems ( accounting data and log files provide important evidence of break-ins) – helpful for alerting you to hardware and software problems. • In general, keep one or two months – in a real world, it may take one or two weeks for SA to realize that site has been compromised by a hacker and need to review the logs
  • 7. Throwing away (cont.) • Most sites store each day’s log info on disk, sometimes in a compressed format • These daily files are kept for a specific period of time and then deleted • One common way to implement this policy is called “rotation”
  • 8. Rotating log files • Keep backup files that are one day old, two days old, and so on. – logfile, logfile.1 , logfile.2, … logfile.7 • Each day rename the files to push older data toward the end of the chain – script to archive three days files
  • 9. #! /bin/sh cd /var/log mv logfile.2 logfile.3 mv logfile.1 logfile.2 mv logfile logfile.1 cat /dev/null > logfile Some daemons keep their log files open all the time, this script can’t be used with them. To install a new log file, you must either signal the daemon, or kill and restart it.
  • 10. #! /bin/sh cd /var/log mv logfile.2.Z logfile.3.Z mv logfile.1.Z logfile.2.Z mv logfile logfile.1 cat /dev/null > logfile kill -signal pid compress logfile.1 signal - appropriate signal for the program writing the log file pid - process id
  • 11. Archiving log files • Some sites must archive all accounting data and log files as a matter of policy, to provide data for a potential audit • Log files should be first rotate on disk, then written to tape or other permanent media – see chap 11, Backups
  • 12. Finding log files • To locate log files, read the system startup scripts : /etc/rc* or /etc/init.d/* – if logging is turned on when daemons are run – where messages are sent • Some programs handle logging via syslog – check /etc/syslog.conf to find out where this data goes
  • 13. Finding log files • Different operating systems put log files in different places: – /var/log/* – /var/cron/log – /usr/adm – /var/adm … • On linux, all the log files are in /var/log directory.
  • 14. Outline • Log files – What need to be logged – Logging policies – Finding log files • Syslog: the system event logger – how syslog works – its configuration file – debugging syslog – the software that uses syslog
  • 15. What is syslog • A comprehensive logging system, used to manage information generated by the kernel and system utilities. • Allow messages to be sorted by their sources and importance, and routed to a variety of destinations: – log files, users’ terminals, or even other machines.
  • 16. Syslog: three parts • Syslogd and /etc/syslog.conf – the daemon that does the actual logging – its configuration file • openlog, syslog, closelog – library routines that programs use to send data to syslogd • logger – user-level command for submitting log entries
  • 17. syslog-aware programs Using syslog lib. Routines write log entries to a special file /dev/log syslogd /etc/syslog.conf reads consults dispatches Log files Users’s terminals Other machines /dev/klog
  • 18. Configuring syslogd • The configuration file /etc/syslog.conf controls syslogd’s behavior. • It is a text file with simple format, blank lines and lines beginning with ‘#’ are ignored. – Selector <TAB> action – eg. mail.info /var/log/maillog
  • 19. Configuration file selector • Identify – source -- the program (‘facility’) that is sending a log message – importance -- the messages’s severity level – eg. mail.info /var/log/maillog • Syntax – facility.level – facility names and severity levels must chosen from a list of defined values
  • 20. Configuration file Facility names Facility Programs that use it kern the kernel user User process, default if not specified mail The mail system daemon System daemons auth Security and authorization related commands lpr the BSD line printer spooling system news The Usenet news system
  • 21. Configuration file Facility names Facility Programs that use it uucp Reserved for UUCP cron the cron daemon mark Timestamps generated at regular intervals local0-7 Eight flavors of local message syslog syslog internal messages authpriv Private or system authorization messages ftp the ftp daemon, ftpd * All facilities except “mark”
  • 22. Configuration file Facility names • Timestamps can be used to log time at regular intervals (by default, every 20 minutes), so you can figure out that your machine crashed between 3:00 and 3:20 am, not just “sometime last night”. This can be a big help if debugging problems occur on a regular basis.
  • 23. Configuration file severity level Level Approximate meaning emerg (panic) Panic situation alert Urgent situation crit Critical condition err Other error conditions warning Warning messages notice Unusual things that may need investigation info Informational messages debug For debugging
  • 24. Configuration file selector • Can include multiple facilities separated with ‘,’ commas – daemon,auth,mail.level action • Multiple selector can be combined with ‘;’ – daemon.level1; mail.level2 action • Selector are ‘|’ --ORed together, a message matching any selector will be subject to the action. • Can contain ‘*’ or ‘none’, meaning all or nothing.
  • 25. Configuration file selector • Levels indicate the minimum importance that a message must have in order to be logged – mail.warning, would match all the messages from mail system, at the minimum level of warning • Level of ‘none’ will excludes the listed facilities regardless of what other selectors on the same line may say. – *.level1;mail.none action • all the facilities, except mail, at the minimum level 1 will subject to action
  • 26. Configuration file action (Tells what to do with a message) Action Meaning filename Write message to a file on the local machine @hostname Forward message to the syslogd on hostname @ipaddress Forward message to the host at IP address user1, user2,… Write message to users’ screens if they are logged in * Write message to all users logged in
  • 27. Configuration file action • If a filename action used, the filename must be absolute path. The file must exist, syslogd will not create it. – /var/log/messages • If a hostname is used, it must be resolved via a translation mechanism such as DNS or NIS • While multiple facilities and levels are allowed in a selector, multiple actions are not allowed.
  • 28. Config file examples # Small network or stand-alone syslog.conf file # emergencies: tell everyone who is logged on *.emerg * # important messages *.warning;daemon,auth.info /var/adm/messages # printer errors lpr.debug /var/adm/lpd-errs
  • 29. # network client, typically forwards serious messages to # a central logging machine # emergencies: tell everyone who is logged on *.emerg;user.none * #important messages, forward to central logger *.warning;lpr,local1.none @netloghost daemon,auth.info @netloghost # local stuff to central logger too local0,local2,local7.debug @netloghost # card syslogs to local1 - to boulder local1.debug @boulder.colorado.edu # printer errors, keep them local lpr.debug /var/adm/lpd-errs # sudo logs to local2 - keep a copy here local2.info /var/adm/sudolog
  • 30. Sample syslog output Dec 27 02:45:00 x-wing netinfod [71]: cann’t lookup child Dec 27 02:50:00 bruno ftpd [27876]: open of pid file failed: not a directory Dec 27 02:50:47 anchor vmunix: spurious VME interrupt at processor level 5 Dec 27 02:52:17 bruno pingem[107]: moose.cs.colorado.edu has not answered 34 times Dec 27 02:55:33 bruno sendmail [28040] : host name/address mismatch: 192.93.110.26 != bull.bull..fr
  • 31. Syslog ‘s functions • Liberate programmers from the tedious mechanics of writing log files • Put SA in control of logging – before syslog, SA had no control over what info was kept or where it was stored. • Can centralize the logging for a network system
  • 32. Syslogd (cont.) • A hangup signal (HUP, signal 1) cause syslogd to close its log files, reread its configuration file, and start logging again. • If you modify the syslog.conf file, you must HUP syslogd to make your changes take effect. – Kill -1 pid
  • 33. Debugging syslog -- logger • Useful for submitting log entries from shell scripts • Can also use it to test changes in syslogd’s configuration file. – For example..
  • 34. Add line to syslog.conf: local5.warning /tmp/test.log verify it is working, run logger -p local5.warning “test messages” a line containing “test messages” should be written to /tmp/test.log If this doesn’t happen: forgot to create the test.log file forgot to send syslogd a hangup signal
  • 35. Software that uses syslog Program Facility Levels Description amd auth err-info NFS automounter date auth notice Display and set date ftpd daemon err-debug ftp daemon gated daemon alert-info Routing daemon gopher daemon err Internet info server halt/reboot auth crit Shutdown programs login/rlogind auth crit-info Login programs lpd lpr err-info BSD line printer daemon
  • 36. Software that uses syslog Program Facility Levels Description named daemon err-info Name sever (DNS) passwd auth err Password setting programs sendmail mail debug-alert Mail transport system rwho daemon err-notice romote who daemon su auth crit, notice substitute UID prog. sudo local2 notice, alert Limited su program syslogd syslog, mark err-info internet errors, timestamps
  • 37. Using syslog in programs • openlog ( ident, logopt, facility); – messages are logged with the options specified by logopt begin with the identification string ident. • Syslog ( priority, messge, parameters…); – send message to syslogd, which logs it at the sepecified priority level • close ( );
  • 38. / * c program: syslog using openlog and closelog */ #include <syslog.h> main ( ) { openlog ( “SA-BOOK”, LOG_PID, LOG_USER); syslog ( LOG_WARNING, “Testing …. “); closelog ( ); } On the host, this code produce the following log entry: Dec 28 17:23:49 moet.colorado.edu SA-BOOK [84]: Testing...
  • 39. Final words • On linux, check following files: – /etc/syslog.conf : syslog configuration file – /etc/logrotate.conf : logging policy, rotate – /etc/logrotate.d/* – /var/log/* : log files • try following commands to find out more... – man logrotate – man syslogd