title: Daemon logging in Linux
body: <p>So I have a daemon running on a Linux system, and I want to have a record of its activities: a log. The question is, what is the "best" way to accomplish this?</p>
  
  <p>My first idea is to simply open a file and write to it.</p>
  
  <pre><code>FILE* log = fopen("logfile.log", "w");
  /* daemon works...needs to write to log */
  fprintf(log, "foo%s\n", (char*)bar);
  /* ...all done, close the file */
  fclose(log);
  </code></pre>
  
  <p>Is there anything inherently wrong with logging this way? Is there a better way, such as some framework built into Linux?</p>