Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming 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
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

log4J and java.util.logging

 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody ,
I have few questions regarding log4J

1)what is the difference between log4J and java.util.logging ?

2)

Why it is declared static final


regards,
S
 
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it should be declared as private also..

It is declared static final so that it will be a compile time constant..

Differece between the two is..
One is the java logging utility while other is the framework for log4j..
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be as

 
Marshal
Posts: 67289
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java.util.logging facility is built into Java; since 1.4. You don't need any external jars to use it.

Log4J is a 3rd-party implementation of a logging package. Most developers find Log4J easier to configure and more feature-rich than the built-in logging.

Apache Commons Logging is a 3rd-party implementation that lets your code use either of the above. If Log4J is detected, it will be used. Otherwise, it reverts to java.util.logging. The advantage is that if the code is distributed, the end user can choose which logging package to use by simply including Log4J in the classpath or not.
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all,
Shanky Sohar could you please describe what t is declared static final so that it will be a compile time constant.. mean and how it is effect on the application ?


regards,
S
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liitle more about log4j
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

s begri wrote:Thank you all,
Shanky Sohar could you please describe what t is declared static final so that it will be a compile time constant.. mean and how it is effect on the application ?


regards,
S



Static : it is available without instantiating the class.
Final : for Preventing the inheritance further ie; the class with final word as prefix cannot be extend further!.

So here

means logger is been decided as the reference of the Hello.class itself at the compile time and its final,you cann't change it to something else.
For a complete application,logger remain as the reference to a hello.class,you cann't change.

if you are not marking it as static then it will be initialed at runtime or if you are not marking it as final then within a class itself you can change the reference of it to
something like
logger = Logger.getLogger(Hello.class);

And you are marking it as private,as you don't want any other class can use this logger just because it is static and cab be access using classname..

So syntax is..


Hope now completely understood..
 
A wop bop a lu bob a womp bam boom. Tutti frutti 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!