Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advantage in using Java Logger?

Tags:

java

logging

I want to log information to a file and want to know is there any advantage in using the Java Logger class versus my own personal method of logging?

I know using a logger I just add my own FileHandler to the logger. My personal method is just using a FileOutputStream.

like image 763
Hank Avatar asked Jun 28 '26 08:06

Hank


1 Answers

Honestly your logger may be as good, it's pretty easy to put in log levels, filtering, etc.

The problem is when you start to put together code from 10 different groups each with their own logging. Some use System.out, some use some custom logger, some use log4j, ...

How do you parse or redirect the output? How do you filter all that output to just show your messages (For instance, filtering options in log4j won't prevent messages being sent straight to System.out).

It's a pretty big bulk change depending on which system you are moving from/to. Better just to use one very common one from the beginning and hope that it's the one everybody else on the project chooses.

like image 138
Bill K Avatar answered Jun 30 '26 21:06

Bill K