How do I check my Linux server service logs?

Asked 2 years ago, Updated 2 years ago, 83 views

US>On Linux servers, you are running services such as nginx, php-fpm, and mysqld.
Is there any software that makes it easy to view log files for these services?

Currently, whenever there is a problem, I check it by typing a command like sudo tail-f/var/log/nginx/error.log, which makes me feel very inefficient.

linux

2022-09-30 19:13

3 Answers

They want to find an error, so tail-f will cause it to hang out, so I think it will be difficult.There are a lot of commercial apps, but ELK stacks (Elasticsearch, Logstash, Kibana) are popular for free and open source.You can easily collect logs, set error detection conditions, and draw graphs.

Each role is

Installation instructions are here.

As an application, Logstash calculates the hash of the stack trace string when an error occurs and stores it as an ID.If you count the frequency of occurrence of the same ID, you can fix the bug fix for frequent errors first, or you can fix it from rare items to prevent it from becoming a big problem.


2022-09-30 19:13

tail-f so I will answer with the assumption that I want to see real-time logs.

There's not much other software to do this.Normally, it's up to the time of display (equivalent to tail without cat or -f), but commercial server management software like Plesk or HDE controller might do it.

If sudotail-f/var/log/nginx/error.log is hard to type, why don't you set alias to .bashrc?

 alias tf = 'sudotail-f'

If you write tf/var/log/... you can run sudo tail-f/var/log/....You can use alias to include the file name.

Also, create a dedicated user to review logs and place it in .bashrc

sudotail-f...

You may want to write .After logging in, the log appears without permission.


2022-09-30 19:13

As others have said, if you show us how you feel convenient, we will be able to give you a more specific answer.

For example, if it is inconvenient to distribute log files, nginx, php-fpm, and mysqld all support syslog output, so if you set up a syslog server and focus on it, you can only check the logs in one place.You can also monitor log files with monitoring software such as Zabbix if you want to raise an alert such as email when a specific string is printed in the log.


2022-09-30 19:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.