title: Logging python to pm2
body: <p>I've got a Python script, started using pm2.</p>
  
  <p>Is it possible to get realtime logs without stopping the Python script via pm2?</p>
  
  <pre><code>import zerorpc
  import logging
  
  class MyServer(object):
  
          def call(self):
                  logging.info('hello : info')
                  logging.warn('hello : warn')
                  logging.error('hello : error')
                  print('hello : print')
                  return 'Hello'
  
  if __name__ == '__main__':
          s = zerorpc.Server(MyServer())
          s.bind('tcp://0.0.0.0:4243')
          s.run()
          print('hello: right after run')
  </code></pre>
  
  <p>This is a sample code for testing purposes, it uses zerorpc as a server, but I get the same behavior with flask with its integrated webserver.</p>
  
  <p>Start this script from the command line with this command:</p>
  
  <pre class="lang-none prettyprint-override"><code>zerorpc --client --connect tcp://127.0.0.1:4243 call
  </code></pre>
  
  <p>This will write to output: </p>
  
  <pre class="lang-none prettyprint-override"><code>WARNING:root:hello : warn
  ERROR:root:hello : error
  hello : print
  </code></pre>
  
  <p>But starting this with pm2 will output:</p>
  
  <pre class="lang-none prettyprint-override"><code>zero_rpc_server-7 WARNING:root:hello : warn
  zero_rpc_server-7 ERROR:root:hello : error
  </code></pre>
  
  <p>We lost the print, and all goes to error pm2 logs.
  Any idea to log to pm2 out logs?</p>