Solved Using the syslog API

Hello I am trying to write a basic program that uses the syslog API to log information but I am having problems with it, it does not write to any of the files I specify. The program is just something bare bones that I threw together in order to learn to use syslog. I have changed my /etc/syslog.conf file more than a few times and changed the priority and facility of the syslog function a few times. Here is my code:

#include <stdio.h>
#include <syslog.h>
#include <unistd.h>
#include <sys/types.h>

int main(int argc, char *argv[])
    openlog("syslog_process", LOG_CONS | LOG_PID, LOG_DAEMON);
    syslog(LOG_NOTICE, "Hello from Syslog");

    return 0;

Here is my syslog.conf:
# $FreeBSD: releng/10.3/etc/syslog.conf 260519 2014-01-10 17:56:23Z asomers $
#       Spaces ARE valid field separators in this file. However,
#       other *nix-like systems still insist on using tabs as field
#       separators. If you are sharing this file between systems, you
#       may want to use only tabs as field separators here.
#       Consult the syslog.conf(5) manpage.
*.err;kern.warning;auth.notice;mail.crit                /dev/console
*.notice;authpriv.none;kern.debug;;mail.crit;news.err   /var/log/messages
security.*                                      /var/log/security;                         /var/log/auth.log                                       /var/log/maillog                                        /var/log/lpd-errs                                        /var/log/xferlog
cron.*                                          /var/log/cron
*.=debug                                        /var/log/debug.log
*.emerg                                         *

# uncomment this to log all writes to /dev/console to /var/log/console.log
# touch /var/log/console.log and chmod it to mode 600 before it will work                                   /var/log/console.log
# uncomment this to enable logging of all log messages to /var/log/all.log
# touch /var/log/all.log and chmod it to mode 600 before it will work
#*.*                                            /var/log/all.log
# uncomment this to enable logging to a remote loghost named loghost
#*.*                                            @loghost
# uncomment these if you're running inn
# news.crit                                     /var/log/news/news.crit
# news.err                                      /var/log/news/news.err
# news.notice                                   /var/log/news/news.notice
# Uncomment this if you wish to see messages produced by devd
# !devd
# *.>=notice                                    /var/log/devd.log
*.*                                             /var/log/ppp.log
As you can see all messages with the LOG_NOTICE level should be logged to /var/log/messages. This is not happening though and I have run my syslog program as root thinking it was a permissions issue but nothing shows up in /var/log/messages. I have changed the files around and changed both the facility and level of the syslog messages and sometimes I will get something printed to /dev/console (due to having the LOG_CONS option, which causes it to print to /dev/console on error) but that is about it.
Your C code looks fine for a simple test, and outputs to /var/log/messages as I would expect, testing it on 10.3.

Are you running a standard FreeBSD 10.3 i386/amd64 system (I can see your syslog.conf is based on the default 10.3 version, but that does not tell me the actual version of your system)? Is there anything unusual / non-standard about the system or the user environment you are using to run your test code?

Things to check:
  • Is syslogd(8) running (it should be enabled by default, and needs to run as root)?
  • Did you reload it after changing /etc/syslog.conf (either service syslogd reload, or send it a SIGHUP)?
  • Do the socket files exist, /var/run/log (perms 0666) and /var/run/logpriv (perms 0600), and can the user running the code see into /var/run?
  • Do you have any syslogd_* options set in /etc/rc.conf?
  • Are you getting anything logged to /var/log/messages (i.e. anything at all, from other things on your system)?
  • Are things logging as expected to /var/log/* in general?