Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between logging and printing to the console

This is kind of a philosophical question.

Basically people often ask if I am logging - and since I am not a full time programmer, but someone who programs often but is actually more of a requirements analyst, I don't know all the best practices.

I use Java a lot so I often do things like

System.out.println()

What's the difference in theory between the two? Ultimately aren't I also logging? Esp, if I prefix my comments with something like "ERROR:" or "WARN:" ?

like image 507
Ankur Avatar asked May 16 '10 09:05

Ankur


2 Answers

Logging is an abstract way of printing to console. Using proper logging framework you specify what information you want to log and what is the importance of it. The configuration of a logging framework then decides whether:

  • Put it in /dev/null
  • Print it on console
  • Send a mail to admin
  • Send a mail to developer
  • Send message to IRC
  • Send an UDP packet to logging server
  • Do any other automatic response

I'd say printing on console is a primitive way of logging. Certainly it helps in some situations but it is not very flexible and for sure is not suitable for servers.

like image 142
Maciej Piechotka Avatar answered Nov 08 '22 20:11

Maciej Piechotka


Logging is when you're writing to files for future analysis.

Printing to the console is... well it's just printing to the console!!!

In my opinion they're not interchangeable

like image 44
Paligulus Avatar answered Nov 08 '22 19:11

Paligulus