Use of syslog on Solaris

xiaoxiao2021-03-06  63

Syslog.conf

This file is in the / etc directory to control how Syslogd handles a log message for a Facility | Priority. For example, you can store a log message of a Facility | Priority to a specified file or send it to another log server or notify the currently logged in.

In this configuration file, '*' can be used to specify all facilities, but cannot be used to specify all priority; pay attention to facility | priority, you cannot have spaces, otherwise syslogd will ignore the configuration. The following configuration is incorrect:

User. * [Tab] /var/USR.log

User.err [Space] [Tab] /var/usr.rr.log.

After modifying the configuration file, you need to run the command to make the new configuration:

Kill -hup `cat / etc / syslog.pid`; or restart the syslogd server:

/etc/init.d/syslog stop

/etc/init.d/syslog start

> /VAR/ADM/MESSAGES.0 command to empty the diary file

Typical syslog.conf files are as follows:

Logger

This is an executable program that is used to simulate the log message to the SyslogD server to simulate the Syslogd server. E.g:

Logger -p user.warning "Hello, I am Logger"

Newsyslog

This is a scriptor, located in the / usr / lib directory, used to roll back the log file. The rollback here refers to: back up the log file to another directory, empty the log file, and automatically delete the expiration log file in the backup directory. A typical newslog script file is as follows:

#! / bin / sh

#

# / usr / lib / newsyslog - Rotate log files (loghost)

#

LogDir = / var / log

IF test -d $ logdir

THEN

CD $ logdir

For log in message auth.log daemon.log lpr.log mail.log news.log user.loguucp.log; do

TEST -F $ log.6 && mv $ log.6 $ log.7

TEST -F $ log.5 && mv $ log.5 $ log.6

TEST -F $ log.4 && mv $ log.4 $ log.5

TEST -F $ log.3 && mv $ log.3 $ log.4

TEST -F $ log.2 && mv $ log.2 $ log.3

TEST -F $ log.1 && mv $ log.1 $ log.2

Test -f $ log.0 && mv $ log.0 $ log.1

TEST -F $ log && mv $ log.0

CP / DEV / NULL $ log

CHMOD 640 $ log

DONE

Fi

/ bin / kill -hup `cat / etc / syslog.pid`

# end of file / usr / lib / newsyslog

The newsyslog script needs to be executed by the cron program.

转载请注明原文地址:https://www.9cbs.com/read-111408.html

New Post(0)