aspose file tools*
The moose likes Other Open Source Projects and the fly likes log4j vs JDK logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "log4j vs JDK logging" Watch "log4j vs JDK logging" New topic
Author

log4j vs JDK logging

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Can any one tell me why log4j is more popular than JDK Logger API. Yes, I know that log4j work with the older JDKs.


Groovy
sunitha reghu
Ranch Hand

Joined: Dec 12, 2002
Posts: 937
check this thread
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Sunitha
The thread is dated 2001, not sure if it holds good today.
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
It's been around longer.
Mike Wang
Ranch Hand

Joined: May 09, 2003
Posts: 76
Originally posted by Pradeep Bhat:
Can any one tell me why log4j is more popular than JDK Logger API. Yes, I know that log4j work with the older JDKs.

1. Log4j come into word earlier than JDK logging API.
2. Log4j works for older JDK.
3. Log4j is more configuarable than JDK logging API.
4. Log4j has proven product quantity. etc. JBoss use it!


SCJP1.4<br />SCWCD 1.4 (Beta)<br />SCMAD 1.0 (Beta)<br />SCDJWS (Beta)<br />SCBCD 1.3 <br />SCJD <br />SCEA (Prepairing)<br />"I am mike, not milk"
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Log4j is more configuarable than JDK logging API.

Could you please elaborate more?
vasu maj
Ranch Hand

Joined: Jul 12, 2001
Posts: 395
Log4j is used by default as people have been using it for a long time. Java's logging api is relatively new and it needs to be really far better for people to take notice. I don't know if it is the case. It looks like it is not.

Thanks,
Vasu


What a wonderful world!
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by vasu maj:
Java's logging api is relatively new and it needs to be really far better for people to take notice.
Actually, I strongly believe that the JDK Logging API will become the de facto standard because it's already there. The old-timers may choose Log4J over the standard Logging API on the basis of technical merit, but the newcomer will pick what's taught in the textbook of "Java Programming 101."
In fact, I didn't think twice using java.util.logging over Log4J in my current/past project. We didn't need the extra functionality provided by Log4J and valued the ease of use of the java.util.logging package.
Obviously your mileage may vary (and it almost certainly does), but the standard Logging API is probably already sufficient for most "enterprise" web applications out there.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

I has read that JDK loggin perform better than log4j.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

We didn't need the extra functionality provided by Log4J

what is that extra functionality?
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
J2SDK logging performs well with minimal configuration.
That said we're using a logging class we rolled ourselves (but it was created by someone coming from C who might not have known there was integrated logging functionality in Java now).
It's simple, fast, and does what we want it to without having to configure a big logging framework for simple things.


42
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Pradeep Bhat:
what is that extra functionality?

More flexible configuration options like logging to a JDBC connection, to Windows NT event logs, to SMTP servers, over a TCP socket, etc.
Oh, I forgot one: rolling log files based on date instead of just file size.
[ April 15, 2004: Message edited by: Lasse Koskela ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Jeroen Wenting:
It's simple, fast, and does what we want it to without having to configure a big logging framework for simple things.
That sounds very much like the reasoning I did for using the Logging API instead of Log4J...
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

I have a question regarding disabling logging
Isn't it better to have


rather than

with logging disabled in some properties file.
Note that the first approach avoids method calls. :roll:
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
In theory, yes, it would be better from a performance point of view.
However, for most applications/components I would prefer readability over micro-optimization. With a reasonable certainty, the additional method calls the logging framework makes for determining whether the given message should be logged or ignored is not a bottleneck.
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Does it make sense to provide a facility whereby logger statements can also be removed during deployment like asserts?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by karthik Guru:
Does it make sense to provide a facility whereby logger statements can also be removed during deployment like asserts?

I think that assert statements are implemented usinf some sort of if boolean statements. correct me if I am wrong.
[ April 15, 2004: Message edited by: Pradeep Bhat ]
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by Pradeep Bhat:

I think that assert statements are implemented usinf some sort of if boolean statements. correct me if I am wrong.
[ April 15, 2004: Message edited by: Pradeep Bhat ]

oops I thought that they are not even compiled into the bytecode when compiled with some special javac option.
I checked up, You are correct.They can be switched on or off at runtime using the java command line option. So they also incur a boolean check.
friso dejonge
Ranch Hand

Joined: Jul 11, 2002
Posts: 162
oh well everyone fell over this statement so i may as well:
Does it make sense to provide a facility whereby logger statements can also be removed during deployment like asserts?

my question is, have you ever worked in a situation where you have to bugfix a system on a server where you are allowed to see the logfiles, but nothing more ? (no configuration, server names, directories etc) As a person who maintains an application you need to have as much debugging statements as possible, otherwise you cannot fix any bug.
Therefore it may well be possible to get all logger statements out, but hey, give the bugfixers a chance to fix all our bugs.


swimming certificate (A & B), shoelaces diploma, and some useless java ones.
Sean Sullivan
Ranch Hand

Joined: Sep 09, 2001
Posts: 427
Log4j provides more useful appenders.
For example, Log4j provides the SMTPAppender
I ported Log4j's SMTPAppender to java.util.logging
The code is available online: http://smtphandler.sourceforge.net/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: log4j vs JDK logging