What Is Log4j, Why Log4j Came Into Picture

Log4j » on Feb 27, 2012 { 39 Comments } By Sivateja

For logging log4j is the best even today, let us see little history behind this ๐Ÿ™‚

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…

But we have some disadvantages while using SOPL (system.out.println) statements.

  • Generally SOPL statements are printed on console, so there are temporary messages and when ever the console is closed then automatically the messages are removed from the console
  • It is not possible to store the SOPL messages in a permanent place and these are single threaded model, means these will prints only one by one message on the console screen
  • 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
  • Working with log4j is nothing but working with classes & interfaces given in org.apache.log4j.*
  • Log4j is a common tool, used for small to large scale Java/J2EE projects
  • In Log4j we use log statements rather SOPL statements in the code to know the status of a project while it is executing
  • 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


โ€‹ โ€‹โ€‹

You Might Also Like

  ::. About the Author .::

Sivateja Kandula - Java/J2EE Full Stack Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.


39 Responses to “What Is Log4j, Why Log4j Came Into Picture”
  1. veeru says:

    nice introduction by u………..

  2. swapna says:

    You explains in a very simple language and it is very well understood.

  3. @swapna you are true, the way the explanation is too good.

  4. kiran says:

    Can you [lease mail me log4j,json,jquery material

  5. Sir, your all the tutorial’s are Awesome…….

    if Possible, Please provide WEB Services tutorial…….


  6. rajender says:

    XmlLayout output is not a well formatted output

    how to genertaed a well formatted Xml through xmlLayout
    give complte files of Example

  7. chinnarego says:

    now only i understood for log4j…thanks sir……

  8. shubhada says:

    Nyc explanation to begin with log4j…thanks ๐Ÿ™‚

  9. vilkas says:

    Your way of explanation is really super…

  10. krishna says:

    Excellent tutorial!!!! Thank you sir!!!!

  11. lakshmi narayana reddy says:

    Dear sivateja reddy.
    Really good job…………..

  12. suresh says:

    Very good…explanation, nice..Thank you.

  13. Gopinath says:

    i understood, why log4j come in to picture….
    thank u sir …..

  14. Durga says:

    hi ,
    very good introduction about log4j

  15. bhaskara says:

    very nice explanation thanks ,till now i didn’t got thought about log4j.

  16. prayas says:

    to the point explanation !!

  17. krishna says:

    Hi ,
    Siva Teja, its great tutorial i have never seen , could you please provide same
    for spring MVC tutorial with maven project structure , because i have referred lot of tutorial for maven with spring MVC ,no where i found exact solution like java4s so please give at least one example with maven project structure

    Thanks & Regards,
    Krishna Arigela.

  18. shobha says:

    Too good explanation…

  19. Ashok Katherla says:

    Unbelievable this is very nice explanation…

  20. Nageswara Rao says:

    superb thank u yar

  21. Trupti says:


  22. Atul says:

    nice explanation…. thanks a lot..

  23. sreekar says:

    Your nice explanation

  24. surjit kumar says:

    You explained in very simple words and sentences.Now I have understood .Thanks sir

  25. Ranjit says:


    It’s a very nice explanation..
    Each and every thing of this tutorial is matching to the real scenario..
    Great job..

  26. bharath says:

    Your explanation is very quite simple and understandable….Thank you for the assistance.

  27. swati says:

    You Explained very well.

  28. Udaya says:

    Excellent and Simple way of Explanation,
    Thank you

  29. subbarao popuri says:

    Siva Teja Ur site very useful for beginers ๐Ÿ™‚

  30. shaneshwar says:

    it’s very simple to understand

  31. Anjan says:

    Nice Explanation…..

  32. sudhir says:

    I am happy because eaisly understand

  33. Purnachander says:

    it’s very easy to understand and thank you!

  34. kumar says:

    I happy to vist this web site…
    esly undestanble by every one thank u very much……

  35. Siva says:

    The way you have explained is really very much understandable.
    Simple and Strong!

  36. Shalini Gupta says:

    great explanation.

  37. Ranjit Soni says:

    Hello sir,

    I have one question. Suppose i have implemented log4j for logging implementation in Rest Easy Application and I want to log the information in ContainerRequestFilter implementation class. then please tell me user's request will be processed sequentially to print log then process api or both will be process paralleled.
    Please help.


  38. durga rao says:

    Super sir..great explanation.


By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Spring Boot Hibernate Spring
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2024 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.