Remove lfs-uefi.txt symlink
[linux_from_scratch_hints.git] / PREVIOUS_FORMAT / metalog.txt
blobadc8302fa81686603c0a5ded3f72da4f0dffcd1d
1 TITLE:          Using metalog instead of sysklogd
2 LFS VERSION:    3.0-rc1
3 AUTHOR:         Laurence Withers <lwithers@lwithers.demon.co.uk>
5 SYNOPSIS:
6         How to set up and use metalog, a replacement for the
7         system/kernel logging daemon. Metalog is simpler to use, and
8         more powerful. This hint is useful both during building an LFS
9         system, and after you have one set up.
11     See http://metalog.sf.net/ .
13 HINT:
15 0. Contents
16 -----------
18     1. Introduction
19     2. Compiling, installing
20     3. Creating /etc/metalog.conf
21     4. Changing /etc/init.d/sysklogd
22     5. Logging to a console
23     Appendix A. Building LFS with metalog
25 1. Introduction
26 ---------------
28     Why metalog? Well, it is a decent replacement for sysklogd, the
29 package currently used in LFS to perform system and kernel logging. It
30 has a simpler (and yet more powerful) configuration file, supports
31 maximum log file size, rotates old logs, and buffers log messages in
32 memory (thus improving system performance).
34     This hint will walk you through the installation and set up of
35 metalog. Please also read the metalog documentation when creating
36 /etc/metalog.conf; it will let you know about all sorts of options you
37 can use.
39 2. Compiling, installing
40 ------------------------
42     I used version 0.6 of metalog on my system, but these instructions
43 should be useful whichever version you have. Examine the `README' file
44 if you have a different version.
46     Firstly, you need to install the PCRE library (Perl Compatible
47 Regular Expressions). This is available from http://www.pcre.org/ . I
48 used version 3.5, but again, any version should be fine. After
49 extracting the archive and changing to its directory, type:
51 # CFLAGS="-O2" ./configure --prefix=/usr
52 # make
53 # make install
54 # ldconfig
56     Now, installation of metalog is simple. Extract the archive and
57 change to its directory, and type:
59 # ./configure --prefix=/usr
60 # make install-strip
62     Metalog is now installed.
64 3. Creating /etc/metalog.conf
65 -----------------------------
67     Read the metalog README for the exact rules on how to create a
68 configuration file. This file is a good start, however:
70 # /etc/metalog.conf
71 #  Configuration for metalog (replacement for syslog et al.)
73 maxsize  = 100000
74 maxtime  = 86400
75 maxfiles = 3
77 Kernel messages :
79   facility = "kern"
80   logdir   = "/var/log/kernel"
82 Authorisation messages :
84   facility = "auth"
85   facility = "authpriv"
86   logdir   = "/var/log/auth"
88 Daemon messages :
90   facility = "daemon"
91   logdir   = "/var/log/daemon"
93 FTP, mail, news :
95   facility = "ftp"
96   facility = "mail"
97   facility = "news"
98   logdir   = "/var/log/ftp-mail-news"
100 Printing :
102   facility = "lpr"
103   logdir   = "/var/log/printer"
105 Security :
107   facility = "security"
108   logdir   = "/var/log/security"
110 System :
112   facility = "syslog"
113   logdir   = "/var/log/syslog"
115 Serious stuff :
117   facility = "*"
118   minimum  = 2
119   logdir   = "/var/log/critical"
121 # end
123     For each `logdir' mentioned in the above file, you need to
124 create a directory. Metalog will install some files in that directory.
125 The log can be accessed as $logdir/current (for instance,
126 /var/log/critical/current ). For the configuration file above, type:
128 # cd /var/log
129 # mkdir kernel auth daemon ftp-mail-news printer
130 # mkdir critical security syslog
132     You can also delete the old log files: /var/log/*.log . I would
133 recommend doing this once you have rebooted the system and no longer
134 have sysklogd running.
136 4. Changing /etc/init.d/sysklogd
137 --------------------------------
139     In order to get metalog running instead of sysklogd, you need to
140 change the startup script /etc/init.d/sysklogd . You can rename this
141 file to metalog if you like, but I had already set up the symlinks and
142 it was easier to edit the file. Simply copy the following:
144 #!/bin/sh
145 # Begin /etc/init.d/sysklogd
148 # Include the functions declared in the /etc/init.d/functions file
151 source /etc/init.d/functions
153 case "$1" in
154         start)
155                 echo -n "Starting metalog daemon..."
156                 loadproc /usr/sbin/metalog -B
158                 ;;
160         stop)
161                 echo -n "Stopping metalog daemon..."
162                 killproc metalog
164                 ;;
166         reload)
167         echo -n "Reloading system log daemon configuration file..."
168                 reloadproc metalog 1
169                 ;;
171         restart)
172                 $0 stop
173                 /usr/bin/sleep 1
174                 $0 start
175                 ;;
177         status)
178                 statusproc /usr/sbin/metalog
179                 ;;
181         *)
182                 echo "Usage: $0 {start|stop|reload|restart|status}"
183                 exit 1
184                 ;;
186 esac
188 # End /etc/init.d/sysklogd
190 5. Logging to a console
191 -----------------------
193     Unlike sysklogd, metalog doesn't immediately write anything it logs
194 to disk. This means that `tail -f' doesn't really do the job anymore. I
195 use a shell script to print to a console, however. Add the following to
196 /etc/metalog.conf:
198 # start
199 Log to a console :
201   facility = "*"
202   command  = "/usr/sbin/consolelog.sh 12"
203 # end
205     Obviously, you can change the `facility', `minimum', etc. to suit
206 yourself. Also, you can combine `command' and `logdir' in a single
207 entry. See metalog's README for more details. The `12' in the
208 commandline is the VT to print to.
210     Create the /usr/sbin/consolelog.sh script like this:
212 # cat >/usr/sbin/consolelog.sh <<EOF
213 >#!/bin/sh
214 ># /usr/sbin/consolelog.sh
215 >#  For metalog -- log something to a console
217 >echo "$2 [$3] $4" >/dev/tty$1
219 >EOF
220 # chmod +x /usr/sbin/consolelog.sh
222     You can change the formatting of the echo command as needed; $2 is
223 the date, $3 is the name of the program sending the entry, $4 is the
224 entry text, and $1 is the VT to print to.
226 Appendix A. Building LFS with metalog
227 -------------------------------------
229     This is a trivial change to make. Obviously, you no longer need to
230 install the `sysklogd' package. When you come to install this package,
231 install PCRE and then metalog instead (step 2). Rather than creating
232 /etc/syslog.conf and /var/log/*.log, create /etc/metalog.conf (step 3)
233 and its directories. Finally, don't use the LFS-provided
234 /etc/init.d/sysklogd script, use the one given in step 4.