MongoDB syslog isn't working on OSX?

177 views
Skip to first unread message

Pablo Cantero

unread,
Feb 9, 2014, 6:52:07 PM2/9/14
to mongod...@googlegroups.com
Hello

Do I need to some more to enable `syslog` on MongoDB 2.4.9 running on OSX 10.9.1, besides enabling it in the `mongodb.conf`?

$ mongod
$ using syslog ident: mongod.27017

Although it seems to be working when I started  the `mongod` process, I couldn't find any mongo long in my `/var/log/syslog.log`.

Thanks

Greg Donald

unread,
Feb 18, 2014, 7:36:29 AM2/18/14
to mongod...@googlegroups.com
`man syslog` seems to imply the default path is /var/log/system.log,
and that's what I'm seeing when I issue a generic syslog command.
> --
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb
>
> ---
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mongodb-user...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Greg Donald

Stephen Steneker

unread,
Feb 18, 2014, 8:08:27 AM2/18/14
to mongod...@googlegroups.com
Hi Pablo,

It looks like you need to set up some extra rules for syslog in OS X 10.9.1 (I haven't tried on any earlier versions yet). The syslog messages are processed via the ASL (Apple System Log) facility.

I was able to get this working with MongoDB 2.4.9 by adding a new file "/etc/asl/org.mongodb" and matching messages with the syslog ident (mongod.27017). You don't have to call your file "org.mongodb", but it is consistent with the other files that are there. You will have to use `sudo` to create/edit any files in the /etc/asl/ directory.

A few example rules I tested in my /etc/asl/org.mongodb config:

# Log all messages via syslog to a separate mongodb.log
? [= Sender mongod.27017] claim only
* file /var/log/mongodb.log mode=0640 compress format=bsd rotate=seq file_max=5M all_max=20M

# Save all messages to system.log
? [= Sender mongod.27017] file /var/log/system.log

After you change the rules file, you need to send a HUP signal to syslogd:

ps -ef | grep -i '/usr/sbin/syslogd' | awk '{print $2}' | head -1 | xargs kill -HUP


There may be some additional rule tweaks needed but this should be a good starting point.

I would also note that messages to syslog in MongoDB 2.4 do not include stack traces (eg. as are sometimes printed by assertions). These stack traces can be informative for troubleshooting and problem diagnosis. FYI, the logging behaviour has been improved in the MongoDB 2.5 development/unstable releases (see SERVER-8825 and related tickets).

Regards,
Stephen

Pablo Cantero

unread,
Feb 18, 2014, 8:35:18 AM2/18/14
to mongod...@googlegroups.com
Hello

Thanks for both replies! Problem solved. :)

I created the `/etc/asl/org.mongodb` and it worked like a charm. 

It is something that I only needed in the development to use the log rotation, because last time I saw my `mongo.log` was occupying 9GB.

Thanks again
Reply all
Reply to author
Forward
0 new messages