
54
Outputting log information to a Linux log host
Network requirements
•
Send log information to a Linux log host with an IP address of 1.2.0.1/16;
•
Log information with severity equal to or higher than informational will be output to the log host;
•
All modules can output log information.
Figure 19
Network diagram
Configuration procedure
Before the configuration, make sure that there is a route between Device and PC.
1.
Configure the device
# Enable information center.
<Sysname> system-view
[Sysname] info-center enable
# Specify the host with IP address 1.2.0.1/16 as the log host. Use channel
loghost
to output log
information (optional,
loghost
by default), and use
local5
as the logging facility.
[Sysname] info-center loghost 1.2.0.1 channel loghost facility local5
# Disable the output of log, trap, and debugging information of all modules on channel
loghost
.
[Sysname] info-center source default channel loghost debug state off log state off trap
state off
CAUTION:
Because the default system configurations for different channels are different, you need to first disable the
output of log, trap, and debugging information of all modules on the specified channel (
loghost
in this
example). Then configure the output rule as needed so that unnecessary information will not be output.
# Configure the information output rule. Allow log information of all modules with severity equal to or
more severe than
informational
to be output to the log host.
[Sysname] info-center source default channel loghost log level informational state on
2.
Configure the log host
Step 1: Log in to the log host as a root user.
Step 2: Create a subdirectory named
Device
under directory
/var/log/
, and create file
info.log
under
the
Device
directory to save logs of
Device
.
# mkdir /var/log/Device
# touch /var/log/Device/info.log
Step 3: Edit file
/etc/syslog.conf
and add the following contents.
# Device configuration messages
local5.info /var/log/Device/info.log