This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

sysout or logger?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I would like to know if there are any performance benefits in using a logger (like log4j) and using a System.out.println to print debug / info in an application server. I understand that the use of a logging mechanism is better, but has anybody seen a significant difference between them ?

Thanks,
Midhun.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The big one is you can turn logging off declaratively using a logger, you can't do that with system.out.println statements.
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I gonna say 3 benefits for now.:
* You can save the log in a file.
* You can define the level of log. Like, info, debug... This help you like, just showing when the problem is an error.
* You can send the output to more than one exit sysout.

So... go for it! \o/
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think sysout will be faster than logging in DEBUG level. but when your application goes to production, you will not log everything. if you do so you have to face a big performance issue. logger gives you much convenient ways implement logging.
 
Ranch Hand
Posts: 607
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no necessary significant performance penalty of using a logger instead of System.out.println(). The time taken to actually print a statement on console far exceeds any overhead of the actual call.

That does not mean log statements should be used blindly - there can be significant performance problems when using logging (special when writing to a file, with log4j - its synchronized.)

However if the choice is between using Println() and logger then logger give significant benefits with no compromise to performance!
 
Die Fledermaus does not fear such a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!