title: How to log errors in python script (process)
body: <p>I need to log errors in python script which running as process.</p>
  
  <p>My current code:</p>
  
  <pre><code>import ips
  import sys
  import time
  import logging
  import os
  import string
  import json
  import multiprocessing
  import MySQLdb as mdb
  
  from daemon import Daemon
  
  
  logging.basicConfig(format = u'%(levelname)-8s [%(asctime)s] %(message)s', level = logging.INFO, filename = u'/var/log/info.log')
  
  
  class MyDaemon(Daemon):
      def run(self):        
          print 'the script was run'
          logging.info("the script was run")
  
          while True:
  
              [My code Here]
  
              time.sleep(10)
  
  
  if __name__ == "__main__":
      daemon = MyDaemon('/var/run/pid.pid')
      if len(sys.argv) &gt; 1:
          if 'start' == sys.argv[1]:
              daemon.start()
          elif 'stop' == sys.argv[1]:
              daemon.stop()
          elif 'restart' == sys.argv[1]:
              daemon.restart()
          else:
              print "Unknown command"
              sys.exit(2)
          sys.exit(0)
      else:
          print "usage: %s start|stop|restart" % sys.argv[0]
          sys.exit(2)
  </code></pre>
  
  <p>Some times my process shutdown but I doesn't see error report. How I can see error report if process shutdown?</p>