5

I'm a web developer using a MacBook Pro running OS X 10.9.3.

Before I started developing in a Mac, I used Cygwin on a Windows machine to see what was happening behind the scene on my web application. I had a Logging system built in PHP which created log files with all the content of the variables I wanted to debug.

Basically, this Logging system creates another PHP file with all the debug needed and through Cygwin, every time I refreshed my web application in the browser it would refresh itself synchronously and outputted a new print with all my recent code updates.

I've searched everywhere but didn't find any close solution.
The one I'm using right now is using the terminal and writhing:

cat /Applications/MAMP/htdocs/BO_V2/data/logs/log-2014-07-10.php 

But it is not automatic and I have to press +enter every time I want to see what the log file has to show.

On OS X, is there a way to have Terminal or another application refresh the print from my log file every time I refresh my browser window (Chrome, Firefox or Safari)?

  • 7
    The command you want is tail with the -f parameter. However this is they way to do it in Cygwin anyway. Cygwin allows the use of Unix commands on Windows - All these command are already in OSX – user151019 Jul 11 '14 at 17:21
  • I've already tried that but it only returns the last 10 lines of code counting from the bottom. The thing about cygwin was it automatic refresh witch saved me tones of time by the end of each project – CIRCLE Jul 11 '14 at 17:25
  • 3
    What command in cygwin? tail -f filename works on all the Unix systems I have used as well as Cygwin – user151019 Jul 11 '14 at 17:26
25
  • On windows, the Cygwin is a Unix-like environment.
  • OS X (now macOS) is full on UNIX, so there is no need for any additions to get these unix tools.

Open Terminal.app and start with manual pages.

The more and tail -f commands are typical unix commands to page, search, and watch a log file.

For your example, the tail command to watch your log file is:

tail -f /Applications/MAMP/htdocs/BO_V2/data/logs/log-2014-07-10.php
4

Assuming it's the same as on Linux, you could also use:

less /Applications/MAMP/htdocs/BO_V2/data/logs/log-2014-07-10.php

Then press Shift+F to have it tail automatically, or just Shift+G to go to the end of file.

  • 2
    more is already less on OS X / darwin and the shift F/G commands work as advertised. – bmike Jul 11 '14 at 20:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .