title: How to log python program activity in Mac OS X
body: <p>I'm pretty new to Python programming so I have this question:</p>
  
  <p>How can I log a Python application activity into /var/log with Mac OS X?</p>
  
  <p>I tried using syslog module, but it does not seem to write anything. I tried also with the logging module, but I always run into a permission error.</p>
  
  <p>How can I do it?</p>
  
  <p>Update:</p>
  
  <pre><code>import logging
  import time
  LOG_FILENAME = "/var/log/writeup.log" + time.strftime("%Y-%m-%d")
  LOG_FORMAT = "%(asctime)s - %(filename)s - %(levelname)s - %(message)s"
  log = logging.getLogger("main.py")
  log.setLevel(logging.DEBUG)
  ch = logging.FileHandler(LOG_FILENAME)
  ch.setLevel(logging.DEBUG)
  format = logging.Formatter(LOG_FORMAT)
  ch.setFormatter(format)
  log.addHandler(ch)
  </code></pre>