Redirect System.out and System.err

后端 未结 4 1348
情话喂你
情话喂你 2020-12-05 19:37

I have some legacy code (or rather some code we don\'t control but we have to use) that writes a lot of statements to system.out/err.

At the same time, we are using

4条回答
  •  感动是毒
    2020-12-05 20:25

    You should not need to wrap around the custom logging system you are using. When the application initializes, just create a LoggingOutputStream and set that stream on the System.setOut() and System.setErr() methods with the logging level that you desire for each. From that point forward, any System.out statements encountered in the application should go directly to the log.

提交回复
热议问题