Log4j:

Generally, we use System.out.println (“”) statements to debug the application. We use System.out.println (““) statements frequently in a java applications weather it is a client side executing or server side executing code.
While developing Java/J2EE applications, for debugging an application that is to know the status of a java application at its execution time, in general we use System.out.println (“”) statements in the application right…
->With System.out.println (““) statements, the following problems are faced in real time applications…
Disadvantages:
         If there is more number of System.out.println (““) statements in an application then we can’t see all the statements on console, because of console are scrolled up.
         System.out.println (““) statements are temporary i.e., when a console is closed then all statements on console are erased/removed.
         Server side applications, if we put System.out.println (““) statements then they are displayed on server console. But, all may not have console.
Ex: - jboss server.

So, we may lose System.out.println (““) messages.

When an onsite developers wants to report a bug occurred and the status of a project execution at client to offshore developers then it is not possible with System.out.println (““) statements.

To Overcome All System.out.println (“”) problems:

To overcome all the above problems, a java developer has two options.

1).A developer can choose logging to like log4j.It is developed by Apache guys.
2).A developer can choose java logging API. It is belongs to java API.
         In order to overcome the problems of SOPL statements Log4j came into picture, with Log4j we can store the flow details of our Java/J2EE in a file or databases.
         This is a Open Source tool given by Apache, for only java projects, to record or write the status of an application at various places.
         Log4j is a common tool, used for small to large scale Java/J2EE projects
         In real time, after a project is released and it is installed in a client location then we call the location as on-site right, when executing the program at on-site location, if we got any problems occurred then these problems must report to the off showered engineers,  in this time we used to mail these Log files only so that they can check the problems easily.

Log4j is the best option for logging than java logging API. Because, the tool supports logging modifications by without touching source code of the project.

0 comments:

Post a Comment