Home  >  Q&A  >  body text

python - py uses logging collection 2>&1 to output information

As shown below, I want the normal output of logging to an empty file and the error output to server1.err. However, during actual operation, the normal output is also output to server1.err. How can I achieve this and only output the error log to in server1.err? ? ?

阿神阿神2581 days ago851

reply all(2)I'll reply

  • 習慣沉默

    習慣沉默2017-06-22 11:53:26

    Did you use print for log output? If you use the logging module, you should not need to point to the output. You can point info and warning to different loggers

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-06-22 11:53:26

    You first try redirecting only errors and redirecting normally, instead of redirecting both at the same time, to see if the code is wrong.

    reply
    0
  • Cancelreply