Linux Administrator

Real Time Log Monitoring for PHP or Apache Logs in Linux Terminal

real-time-log-monitoring
mm
Written by Santosh Prasad

If you would like to see your php or Apache web server log in real time. You will need to use tail command which print last part of file in real time including all incoming logs to a standard output device like screen.

Real Time Log Monitoring

Tail is useful to :

1. To show log files in real time.
2. Debug and troubleshoot servers problem.
3. Troubleshoot security issue.
4. Also monitor spammers, IP Address, Scripts etc..

Tail basic command syntax:

tail fileName
tail /path/to/log/file
tail [options] /path/to/log/file

For example: If your log file name is /var/log/httpd/access.log, type below command:

# tail -f /var/log/httpd/access.log

If your php fpm error log file name is /var/log/php-fpm/error.log, type below command:

# tail -f /var/log/php-fpm/error.log

You will get some output like below:

"15-Nov-2017 00:38:47] WARNING: [pool php-fpm] child 1099 said into stderr: "
"15-Nov-2017 00:38:47] WARNING: [pool php-fpm] child 1099 said into stderr: "< HTTP/1.1 200 OK
"15-Nov-2017 00:38:47] WARNING: [pool php-fpm] child 1099 said into stderr: "< Content-Type: application/json
"15-Nov-2017 00:38:47] WARNING: [pool php-fpm] child 1099 said into stderr: "< Date: Wed, 15 Nov 2017 06:43:42 GMT
"15-Nov-2017 00:38:47] WARNING: [pool php-fpm] child 1099 said into stderr: "< Server: nginx
"15-Nov-2017 00:38:47] WARNING: [pool php-fpm] child 1099 said into stderr: "< Content-Length: 117
"15-Nov-2017 00:38:47] WARNING: [pool php-fpm] child 1099 said into stderr: "< Connection: keep-alive
"15-Nov-2017 00:38:47] WARNING: [pool php-fpm] child 1099 said into stderr: "<
[15-Nov-2017 00:38:47] WARNING: [pool php-fpm] child 1099 said into stderr: "* Connection #0 to host v2.crocodoc.com left intact"
[15-Nov-2017 00:38:47] WARNING: [pool php-fpm] child 1099 said into stderr: "* Closing connection #0"

By default tail print last 10 line of a file.

You will get a scrolling view of the /var/log/php-fpm/error.log for all incoming entries on screen. To stop simply hit CTRL+C. Please make sure you have access to view log file on the server.

Thank you! for visiting Look Linux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment