Linux Server Security (2nd Edition( [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Linux Server Security (2nd Edition( [Electronic resources] - نسخه متنی

Michael D. Bauer

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







12.3. Testing System Logging with logger


Before we leave the topic of system-logger configuration and use, we
should cover a tool you can use to test your new configurations,
regardless of whether you use syslog or Syslog-ng:
logger.
logger is a command-line application that
sends messages to the system logger. In addition to being a good
diagnostic tool, logger is especially useful for
adding logging functionality to shell scripts.

The usage we're interested in here, of course, is
diagnostics. It's easiest to explain how to use
logger with an example.

Suppose you've just reconfigured syslog to send all
daemon messages with priority warn to
/var/log/warnings. To test the new
syslog.conf file, you'd first
restart syslogd and klogd
and then you'd enter a command like the one in Example 12-22.

Example 12-22. Sending a test message with logger


mylinuxbox:~# logger -p daemon.warn "This is only a test." As you can see, logger's syntax
is simple. The -p parameter allows you to specify
a facility.priority selector. Everything after
this selector (and any other parameters or flags) is taken to be the
message.

Because I'm a fast typist, I often use
while...do...done statements in interactive
bash sessions to run impromptu scripts
(actually, just complex command lines). Example 12-23s sequence of commands works
interactively or as a script.

Example 12-23. Generating test messages from a bash prompt


mylinuxbox:~# for i in {debug,info,notice,warning,err,crit,alert,emerg}
> do
> logger -p daemon.$i "Test daemon message, level $i"
> done This sends tests messages to the daemon facility for each of all
eight priorities.

Example 12-24, presented in the form of an actual
script, generates messages for all facilities at
each priority level.

Example 12-24. Generating even more test messages with a bash script


#!/bin/bash
for i in {auth,auth-priv,cron,daemon,kern,lpr,mail,mark,news,syslog,user, uucp,
local0, local1,local2,local3,local4,local5,local6,local7}
# (this is all one line!)
do
for k in {debug,info,notice,warning,err,crit,alert,emerg}
do
logger -p $i.$k "Test daemon message, facility $i priority $k"
done
done Logger works with both syslog and Syslog-ng.


/ 94