In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to manually add messages to Linux Syslog files. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
A log file is a file that contains a set of records (or list of events) that have been recorded by the system itself. Using log files, system administrators can track what happens on a specific date or at a specific time. Administrators typically use log files for troubleshooting. Log files are automatically generated and saved in the public directory-/ var / log /. We can also manually add messages to the Linux Syslog file. For example, after you set up the log server, you may want to check that the log server is functioning properly. To do this, we can manually add some entries to the log file to test the log server. This is where logger commands come in handy.
Use the Logger command to add messages to the Linux Syslog file
The ogger command is part of the util-linux package, so please do not install it. Here are some examples:
It is absolutely easy to add entries to the Syslog file manually! A typical use of the logger command is:
Logger file.txt$ cat file.txt This is test file
Now, add the contents of file.txt to the Syslog file using the following command:
$logger-f file.txt
Check the log file:
$tail-l / var/log/syslog [...] Jan 31 08:43:06 ubuntuserver sk: This is test file
If there are any blank lines in the input file, you can exclude them from being added to the log file using the-e flag shown below.
$logger-e-f file.txt
Priority to log messages
Messages can be logged with a given priority.
$logger "Welcome To OSTechNix"-priority user.warning
The default priority is user.notice. Refer to the logger man page for all available priority options.
Send inputs and messages from "stdin" to the Syslog
We can use the command to enter from the bracket input, and then use the following command to push it into the Syslog:
$echo "Welcome to OSTechNix" | logger
The logger sends messages to the remote log server
To send a message to a remote syslog server running on a specific port, run:
$logger "Welcome to OSTechNix"-server-port
Or
$logger "Welcome to OSTechNix"-n-p
The default port number is 514.
Limit the size of messages
We can use the-size flag to set the maximum message size allowed.
$logger-size 5 abcdefghijklmnopqrswxyz
View the log message size:
$tail-l / var/log/syslog [...] Jan 31 09:09:02 ubuntuserver sk: abcde
The default value is 1KiB characters.
$man logger Thank you for your reading! On "how to manually add messages to the Linux system log file" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.