This article introduces how I use the Synology Log Center to record all the logs of my home host.
In Synolog's log center, we can search through its UI.
In this way, we can centrally view our logs, such as the scheduled execution status of Linux hosts.
It can also send messages to the log center through commands, and we can check the daily backup tasks of the Linux host at any time, whether the backup is successful or failed, etc.
Before starting, let's look at the results after setting:
He can instantly show whoever hacked into my computer 😩 (you won't succeed, don't try again, I guess it should be a random scanning robot).
We can also select logs from other servers in the log center and filter the content
We can write a simple Bash to send a message to the log center
For example, in Linux, you can directly write a function and put it in ~/.bashrc.
function log {
logger -p local0.info "$@"
}
After reading so much, how to set it up, don’t worry it’s so simple
1. In the log center of the NAS, click Log Receive, and add a new receiving rule.
2. The next point is the key point. The setting is very simple, but to be honest, I have also studied it for a long time.
If you haven't tried it yet, give it a like after reading it. If you want to use it, it should save a lot of time😝.
In the Linux system, if you have /etc/rsyslog.conf, you can basically use it. I have tested it on Raspberry Pi and Ubuntu, and there is no problem.
Please add the template in RFC3164fmt format to rsyslog.conf.
$template RFC3164fmt,"<%PRI%>%TIMESTAMP% %HOSTNAME% %syslogtag%%msg%"
For example the content below
# /etc/rsyslog.conf configuration file for rsyslog
#
# For more information install rsyslog-doc and see
# /usr/share/doc/rsyslog-doc/html/configuration/index.html
$template RFC3164fmt,"<%PRI%>%TIMESTAMP% %HOSTNAME% %syslogtag%%msg%"
##################
#### MODULES ####
##################
In Ubuntu, there should be a /etc/rsyslog.d/50-default.conf file, please fill in the IP of your Nas in the last line.
Below is my Nas IP 192.168.99.130, you should replace it with your own Nas IP.
豆豆龍風格,我喜歡讓您看最真實的設定,不會像有些文早會打成
#daemon,mail.*;\
# news.=crit;news.=err;news.=notice;\
# *.=debug;*.=info;\
# *.=notice;*.=warn /dev/tty8
*.* @192.168.99.130:514;RFC3164fmt
If you do not have this file on the Raspberry Pi, you can create one yourself, just restart the rsyslog service
systemctl restart rsyslog
There is no rsyslog on MacOS. The macOS I use is 13.0.1 (22A400). If you are an old version, you can try it, but it may not be useful.
I added it directly in /etc/syslog.conf, and then restarted the Mac and it should take effect.
# Note that flat file logs are now configured in /etc/asl.conf
install.* @127.0.0.1:32376
*.* @192.168.99.130:514
Then if you are using MacOS, you can use syslog on your MacOS to test whether the message can be sent to the log center.
$syslog -s -l Info -r 192.168.99.130 TEST1
$ syslog -s -l Error -r 192.168.99.130 TEST1
$ syslog -s -l Debug -r 192.168.99.130 TEST1
The result is as follows:
If you have a Juyi Router, you can also try the following settings. After I tested it, the logs can be sent to the Synolog log center normally.
If you think this article is helpful to you, remember to give it a like, and see if the SEO of this article can rush to the ranking🥹
No Comment
Post your comment