5

If I run a command line service like mongod , my terminal window will continue to show its log output. If i run it as a homebrew service, which is what mongodb itself recommends for mac, with command brew services start mongodb-community, I won't get any log output.

How do i continually stream the log? For mongod, or other homebrew services?

1
  • 1
    You mustn't confuse service and homebrew service. AFAIK each "homebrew service" started with homebrew service ... has an own log file (depends on the launch agent/daemon plist provided by the package) and is rather launchd related.
    – klanomath
    Commented Dec 11, 2019 at 21:56

2 Answers 2

8

The mongodb-community service logs to the following places:

$HOMEBREW_PREFIX/var/log/mongodb/mongo.log
$HOMEBREW_PREFIX/var/log/mongodb/output.log

Usually this means that they're located in:

/usr/local/var/log/mongodb/

You can continually stream the logs using a command like this in the Terminal:

tail -f /usr/local/var/log/mongodb/*.log
1
  • tail -f *.log of couuurse :)
    – vintagexav
    Commented Jul 20, 2023 at 13:55
0

You have several options to start mongodb and show the mongo log:

  1. Directly in the Terminal window:

    brew services start mongodb/brew/mongodb-community && tail -f -n100 /usr/local/var/log/mongodb/mongo.log  
    
  2. In a second Terminal windows (or a tab) (the second one has to have a known tty device number - you get it e.g. with w or tty):

    brew services start mongodb/brew/mongodb-community; tail -f -n100 /usr/local/var/log/mongodb/mongo.log > /dev/tty001;
    
  3. Send the log to a detached screen:

    brew services start mongodb/brew/mongodb-community && screen -dmS mongolog tail -f -n100 /usr/local/var/log/mongodb/mongo.log
    

    to attach to the screen use screen -d -r mongolog in a second window/tab.

You must log in to answer this question.

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