28

After searching online, the best solution I've found so far is to just make a symbolic link in either "/Library/logs/" or "~/Library/logs/" to get it to show up in the Console application.

I'm wondering if it would be possible to add a new directory or log file to the "root" level directly under the "LOG FILES" section in the console.

Here's a quick screenshot:

OS X Console

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Wilco
  • 32,754
  • 49
  • 128
  • 160

11 Answers11

42

There is one way to get your log files into the console.

You can add a symlink to the log file or log directory to one of the directories in the list. The directory ~/Library/Logs seems like the logical choice for adding your own log files.


For myself I wanted easy access to apache2 logs. I installed apache2 using macports and the default log file is located at /opt/local/apache2/logs.

Thus all I did was create the symlink to that directory.

# cd ~/Library/Logs
# ln -s /opt/local/apache2/logs/ apache2 

Now I can easily use the console.app to get to the logs.

phs
  • 10,687
  • 4
  • 58
  • 84
Tao Zhyn
  • 1,736
  • 2
  • 16
  • 16
8

My solution for macOS Sierra:

First and last step, you must create a hard link from your source (log) directory into (as example) one of existing official log directories, you can seen in console.app.

I take my ~/Library/Logs directory for that.

hln /usr/local/var/log /Users/dierk/Library/Logs/_usr_local_var_log

Cross-posting this great tool for creating hardlinks originally posted by Sam.

Short intro:

To install Hardlink, ensure you've installed homebrew, then run:

brew install hardlink-osx

Once installed, create a hard link with:

hln [source] [destination]

Community
  • 1
  • 1
Dierk
  • 151
  • 1
  • 3
  • 5
  • Can't try it myself as my logs are on different device and I get "hln: Cross-device link" but I think this is the only same-device solution. – George May 19 '17 at 16:56
  • You don’t want to create a hard-link to a directory. https://askubuntu.com/a/525129 – Glutexo Mar 07 '18 at 16:48
4

I actually just came across this option that worked perfectly for me:

Actually if you open terminal and...

$ cd /Library/Logs

then sym-link to your new log directory. eg i want my chroot'ed apache logs as 'www'

$ ln -s /chroot/apache/private/var/log www

then re-open Console.app

drill down into /Library/Logs and you will find your sym-linked directory.

;-)

Mohclips.

http://forums.macosxhints.com/showthread.php?t=35680

Chris Hough
  • 3,389
  • 3
  • 41
  • 80
1

Since Mavericks, symlink behavior as change so "ln - s" doesn't work anymore. use hardlink-osx instead to create an hardlink to your directory (may be installed via homebrew)

Airmoi
  • 35
  • 5
  • Although this definitely works, creating a hard-link is usually a bad idea. See https://askubuntu.com/a/525129 – Glutexo Mar 07 '18 at 16:44
1

Very old post I know but, this is the only way I could get it to work.

cd /Library/Logs
sudo mkdir log_files
sudo ln -s /Users/USERNAME/Sites/website/logs/* log_files
2Steaks
  • 109
  • 1
  • 9
1

In mac os 10.11, you may not be able to link to folder of logs, but instead you need to link to each log of logs folder in side console.

ln -s /opt/local/apache2/logs/error_log ~/Library/Logs/Apache2/error_log
jimtut
  • 2,366
  • 2
  • 16
  • 37
1

In Terminal run this command... append any log file directories you want to add

defaults write com.apple.Console LogFolderPaths -array '~/Library/Logs/' '/Library/Logs/' '/var/log/' '/opt/local/var/log/'

Clintm
  • 4,505
  • 3
  • 41
  • 54
0

I was able to hardlink the files into ~/Library/logs by running:

ln /usr/local/var/logs/postgres.log ~/Library/logs

Notice the absence of -s.

No luck for directories though. OSX Sierra 10.12.6

0

You can just open any text file with console.app and it will add and keep it. Folder's though, no luck on that yet.

deiga
  • 1,587
  • 1
  • 13
  • 32
-1

Just tried to do something similar.

I enter this in terminal, while the Console.app was running.

sudo mkdir -p /usr/local/var/log/apache2
sudo mv /private/var/log/apache2 /usr/local/var/log/apache2/apache2-old
sudo ln -s /usr/local/var/log/apache2 /private/var/log/apache2

Now whenever I open the Console.app it crashes.

Really wish there was a way of adding log files in the files. You CAN do it by dragging and dropping a folder onto the Console.app (given it a directory path as an argument), but the added folder only displays its immediate contents and doesn't allow for recursively descending into folders.

---------EDIT BELOW----------

Nevermind I stupidly did something like this leading to infinite recursion in Console.app

sudo mkdir -p /usr/local/var/log/apache2
sudo ln -s /private/var/log/apache2/apache2 /usr/local/var/log/apache2
sudo mv /private/var/log/apache2 /usr/local/var/log/apache2/apache2-old
sudo ln -s /usr/local/var/log/apache2 /private/var/log/apache2
Tobias
  • 4,397
  • 3
  • 26
  • 33
-4

I don't believe it's possible.

If you're generating log files, you should generate them into one of the standard locations anyway, so this won't be an issue.

Chris Hanson
  • 54,380
  • 8
  • 73
  • 102
  • 5
    The standard locations according to Apple's Console.app don't include Homebrew's /usr/local/var/log, which I'd call pretty standard for anyone who uses the command line in OS X. – Carl G Aug 08 '15 at 16:05
  • 1
    Homebrew is a third-party add-on, it's not part of the OS. It shouldn't be defining its own log locations, it should be using the standard locations just like everything else. – Chris Hanson Aug 08 '15 at 17:57
  • All kinds of product use non-standard log locations, most commonly own their own application folders. Try Glassfish for instance. – Tim Maher-De Troyer Jul 14 '17 at 11:35
  • That means Console won’t pick them up. They should use a standard location if possible, so they’re picked up by Console. – Chris Hanson Jul 19 '17 at 19:34