These are very good questions - in fact I should probably add them as FAQs to 
the web site.

Log4j 2 is very new. Currently, the only article written about it is in German 
in a recent issue of Java Magazine - 
http://it-republik.de/jaxenter/java-magazin-ausgaben/Platform-as-a-Service-000514.html.

I received an email yesterday recommending we add a "Switching from Log4j 1.x" 
page to the site. Your questions confirm that that would be a very good idea. 

In reference to how to use Log4j 2 in your application, some simple examples of 
how to use it can be found at 
http://logging.apache.org/log4j/2.x/manual/api.html and the other pages that 
document the APi. 

To understand the differences you should understand that log4j 1.x was created 
quite a long time ago. After a while the primary author of Log4j created SLF4J 
and Logback in an effort to improve both the API and the implementation. Log4j 
2 attempts to learn from both Log4j 1.x and SLF4J and Logback and improve on 
them.   So the areas of incompatibility are:
1. Obtaining a logger. In Log4j 1.x you would do Logger.getLogger() or 
LogManager.getLogger(). Log4j 2 only supports LogManager.getLogger().
2. Log4j exposed its inner workings through the Logger class. You could access 
the Logger repository and other internal things that should not have been part 
of the general APi.
3. In Log4j 1.x Level uses the practice of using int values. Level in Log4j 2 
is an enum.
4. Log4j 1.x had a Priority class (synonymous with Level) and a Category class 
(synonymous with Logger).  Priority and Category do not exist in Log4j 2.
5. Log4j 1.x supports property files and XML to configure it. Log4j 2 supports 
XML and JSON. The XML configuration format is different in Log4j 2 than it was 
in Log4j 1.
I'm sure there are other things but these are the main ones that come to mind.

However, Log4j 2 also provides a "compatibility bridge" between code that uses 
Log4j 1.x Log4j 2.  It doesn't support everything (such as accessing Logger 
repositories) but most code written for Log4j 1.x should work. But even then 
the configuration file format will still be different.

As for the "Best" option, that depends on what your requirements are.  I have 
been working on Log4j 2 primarily because I need a good logging framework that 
can meet the requirements of audit logging in banking applications and have 
found that no other framework meets them. But since it will be replacing 
another logging framework it has to be on par in its fundamental operation with 
that framework.  That said, Log4j 2 is still in alpha status for a reason - it 
needs more testing from a variety of end users to shake out whatever issues 
there may be.  Log4j 1.2 has been around for a long, long time and has met the 
needs of many applications, but it also has some very serious defects that 
can't easily be fixed - especially since it is targeted at fairly old versions 
of the JDK.  The other viable alternative is SLF4J/Logback which also has a 
proven track record - and may meet your needs if you are doing diagnostic and 
debug logging.

Please feel free to ask other questions you may have and we will be happy to 
try to provide the answers.

Ralph


On Aug 24, 2012, at 9:21 PM, Danesh Kuruppu wrote:

> Hi All,
> 
> 
> 
> I am new to this log4j logging scheme and I am going to use this for our
> application.
> 
> I had going through different articles regarding this and I am currently
> interested on using log4j 1.2.17 package.
> 
> 
> 
> I came to know that you have release new log4j 2 alpha version. But I
> wouldn’t find any articles written for log4j 2 package (How we going to use
> it, What are the difference in implementation with log4j 1.2.17, etc)
> 
> 
> 
> They have mentioned that *The API for Log4j 2 is not compatible with Log4j
> 1.x*, I have some questions regarding this
> 
> 
> 
> What are the different in implementation when we go for log4j 2?
> 
> (Comparing with log4j 1.2.17 which I am currently interested for)
> 
> 
> 
> What do you mean by “not Compatible”?
> 
> 
> 
> Since I am a fresher for this login scheme, What is the BEST option I would
> take (log4j 2 package or log4j 1.2.17 package)
> 
> 
> 
> Can you also share some articles written for log4j 2 alpha version.(How we
> are going to use it in our application)
> 
> 
> 
> Looking for quick response
> 
> 
> 
> Thanks
> 
> 
> Danesh

Reply via email to