• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

log4J and java.util.logging

 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should be as

 
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Run away! Run away! Here, take this tiny ad with you:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic