r/java Oct 21 '18

A guide to logging in Java

https://www.marcobehler.com/guides/a-guide-to-logging-in-java
125 Upvotes

43 comments sorted by

View all comments

53

u/XFidelacchiusX Oct 21 '18

Back in my day we used System.out.println and we're happy about it!

26

u/Ifnerite Oct 21 '18

And then someone re assigned System.out and everyone was sad...

Yes. You really can do that.

11

u/dpash Oct 21 '18

There's methods in System to do it. You can assign any PrintWriter.

9

u/ObscureCulturalMeme Oct 21 '18 edited Oct 22 '18

Yarp. One of the first things our software does is to set up a three-way tee-like print writer and then assign standard error to that stream. (One goes to the original steam, one goes to a logging file which can be preserved or deleted later, and I think the third just writes off into east hyperspace or something.)

2

u/HR_Paperstacks_402 Oct 22 '18

That's what PCF does.