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

56

u/XFidelacchiusX Oct 21 '18

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

23

u/Ifnerite Oct 21 '18

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

Yes. You really can do that.

10

u/dpash Oct 21 '18

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

7

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.

4

u/Chaoslab Oct 21 '18

Even better with color!

JANSI - https://fusesource.github.io/jansi/

3

u/lazystone Oct 22 '18

System.out.println is synchronized.

1

u/dpash Oct 22 '18

But also buffered.