Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Log4J

 
Allan Moster
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out has been our way of debugging our JSP pages. The result is always polluted source codes. Does anyone here use Log4J? Can you share your experience? Pros and Cons?
Thanks.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I've used it on a couple of projects and I LOVE it. I'm recommending it for every project now.
The coolest features are the way it automatically "filters" levels of what goes to output without having to put that in your code, and the ability to go to multiple destinations (files, sockets, etc....)
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
Allan Moster
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kyle,
I've created a new project in VisualAge called Log4J and imported the log4j.jar into this new project. It complained that there's a problem with the SMTPAppender class. Did you encounter this?
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that you need to import Sun's javamail classes... I generally have them in another project too, so I haven't seen this yet.
I doublechecked in my VAJ workbench and just confirmed that this is true -- you get the error if you remove the Javamail classes, but it disappears if you re-add them.
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
[This message has been edited by Kyle Brown (edited November 17, 2001).]
 
Allan Moster
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kyle for you help. I played with it last weekend and wow, it is pretty good! Instead of using System.out to print out info messages I can now use these five methods: logDebug, logInfo, logWarning, logError, and logFatal. My config file sets up which files are being logged to, and what severity of messages are being logged. Really cool!
The only problem now is how to sell this idea to the rest of the team. Can i say that this is the de-facto standard now in the industry?
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I wouldn't say it's the "defacto standard" but it sure is commonly used. I've seen it in dozens of projects at large companies. Just jump on the mailing list and look at the addresses users post from!
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going to use Log4J on a jsp page then you really neeed to get the Loggin TagLib. With that you don't write scriptlets to log a message you just put in a tag like < log:debug message="this is a message"/> It also has a tag that allows quick Dumping of all variables in a given scope to the log file.
 
Ashik Uzzaman
Ranch Hand
Posts: 2373
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any link for Log4J for Windows platform(i use win2k server)?

------------------
Muhammad Ashikuzzaman (Fahim)
Sun Certified Programmer for the Java� 2 Platform
--When you learn something, learn it by heart!
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no difference between Log4J on Windows or any other platform -- it's 100% pure Java. The Log4J Home Page gives you more information on downloading it.
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although it may not be pervasive enough to be called the de facto standard, it probably is the most popular logging solution after System.out. To convince your colleagues you might point out that it was a major inspiration behind the Java 1.4 Logging API. Indeed, the resemblance is striking.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic