Hi there Stackoverflow hackers!

I have a very minor case of serious problem, or misunderstanding between me, and the C syslog() function.

The code compiles just fine, and I can see its doing its "dummy job" (pinging 8.8.8.8), but the defined log just does not append. I am completly puzzled by this, and have no idea what could be wrong. Already SMAO (Searched My Ass Off - trying to popularize that) but just can't get it working properly.

Code here:

#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <syslog.h>
#include <string.h>

// Application settings # TODO: import these from a .ini file

#define WORKDIR   "/var/run/management"
#define LOGDIR    "/var/log/management"
#define LOGFILE   "/var/log/management.log"
#define SCRIPTDIR "/var/spool/management"
#define PIDFILE   "/var/run/management/daemon.pid"

int main(void) {
  printf("Management Daemon\nInitializing...");
  pid_t pid, sid;

  setlogmask(LOG_UPTO (LOG_NOTICE));
  openlog(LOGFILE, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
  syslog(LOG_NOTICE, "Management Daemon started by User %d", getuid());
  closelog();

  printf("Done.\nForking...\n");

  pid = fork();
  if(pid < 0) {
    printf("Fork failed! Exiting...\n");
    // TODO: syslog facility

    syslog(LOG_EMERG, "Forking failed, exiting.");
    closelog();

    exit(EXIT_FAILURE);
  }
  if(pid > 0) {
    FILE *pidfile;
    pidfile = fopen(PIDFILE, "w");
    fprintf(pidfile, "%d\n", pid);
    fclose(pidfile);
    printf("PID written to %s\nUsing log file %s\nGoing silent...\n", PIDFILE, LOGFILE);
    // TODO: syslog facility

    openlog(LOGFILE, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
    syslog(LOG_NOTICE, "Fork returned with valid PID: %d. PID file: %s", pid, PIDFILE);

    exit(EXIT_SUCCESS);
  }

  umask(0);

  sid = setsid();
  if(sid < 
Edit
Report