October 7, 2015

Log4J Configuration

In this post i will discuss about Log4J and Log files.

Log file is just simple file, which keep track of the record or event or info when any event happens or any software run. This whole process known as logging. We can create log file as simple log file.

Why Log file is required:

We can create log file for our simple script also so we can track or debug our script easily if anything goes wrong in script. For example, if our script is failing at some point then we can track back what went wrong

What is log4J
Log4j is free open source tool  for creating log files It help us to generate log file.

Log4j is very lightweight and simple logging framework, comprising of three main components

Download Log4J jar file.

1. Navigate to http://mvnrepository.com/
2. Search for Log4J
3. Download latest version of log4J

Create a sample Java project and add log4J. jar file to project.

Create a properties file 
Right click on Project --New --File
give a name log4j.properties.
and add below code in that file

Create a Class file with below log levels:

logger.debug("Sample debug message");
logger.info("Sample info message");
logger.warn("Sample warn message");
logger.error("Sample error message");
logger.fatal("Sample fatal message");

Below is the sample code:

After executing test you can see logs in log4j.log file and in console as well.

OUTPUT of Log4J file:


  1. Replies
    1. A IEEE project is an interrelated arrangement of exercises, having a positive beginning and end point and bringing about an interesting result in Engineering Colleges for a particular asset assignment working under a triple limitation - time, cost and execution. Final Year Project Domains for CSE In Engineering Colleges, final year IEEE Project Management requires the utilization of abilities and information to arrange, plan, plan, direct, control, screen, and assess a final year project for cse. The utilization of Project Management to accomplish authoritative objectives has expanded quickly and many engineering colleges have reacted with final year IEEE projects Project Centers in Chennai for CSE to help students in learning these remarkable abilities.

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
      Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

  2. really informative blog you have posted. i have ever seen such kind of article. so keep on sharing such kind of an interesting article.
    selenium training in chennai

  3. we are the leading oracle fusion financials training institutes search engine.
    we have huge database regarding oracle institutions present in india. we can provide
    complete institute details as we don't have money charge policy for the information

    Oracle fusion Financials Online Training in Ameerpet

    Oracle Fusion Financials Training in Ameerpet


  4. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.

    software testing course in chennai

  5. I have read your blog and i got a very useful and knowledgeable information from your blog.You have done a great job .Please visit our page Selenium Training in Chennai | Selenium Training institutes in Chennai

  6. thank you for sharing nyce information really very nice sap mm training

  7. Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us @ Best Travels in Madurai | Tours and Travels in Madurai | Madurai Travels

  8. I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts.
    Cyber Security Projects for Final Year

    JavaScript Training in Chennai

    Project Centers in Chennai

    JavaScript Training in Chennai