How to view Log file content using Mac Terminal


















There are multiple ways to view a log file using the Mac Terminal. Let's take a look at a few of them.


Option 1: Using cat command

cat /var/log/system.log

Sep  5 00:29:28 C2cs-MacBook-Air syslogd[121]: ASL Sender Statistics
...
...

This will display the content of the entire log file at once and if the file is huge, it is less convenient.


Option 2: Using less command

less /var/log/system.log

Sep  5 00:29:28 C2cs-MacBook-Air syslogd[121]: ASL Sender Statistics
...
...

You will see the contents of the file, one page at a time, and press the spacebar to view more.


Option 3: Using the tail command

tail -30 20230901_server.logs

If you are interested in what was added to the log file recently, then it is better to make use of the tail command with the number of lines that you want to display on the console.


Best Option: Follow the logs in real-time

Most of the time the use-case is to observe the logs in real-time to see what is happening on the server's end, in such case you can follow the logs using the tail command with a -f flag.

tail -f -30 20230901_server.logs
See Server Logs using Mac Terminal Example
-

Facing issues? Have Questions? Post them here! I am happy to answer!


Author: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X





























Copyright © Code2care 2023 | Privacy Policy | About Us | Contact Us | Sitemap