Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This Page is under construction


Find all the steps for Log4j Purging

 Prerequisite
  • Java
  • Eclipse latest version
 Steps For Setup

Step 1:

  • Add log4j dependency in pom.xml
log4j dependency

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>

Step 2:

  • Basic program to store content in log file
Program

package com.cognizant.devops.Log4jProject;



import org.apache.log4j.BasicConfigurator;

import org.apache.log4j.Logger;

 

public class Log4jHelloWorld {

 

    static final Logger logger = Logger.getLogger(Log4jHelloWorld.class);

 

    public static void main(String[] args)

    {

        //Configure logger

   

        BasicConfigurator.configure();

        for(int i=0;i<20000;i++)

        {

        System.out.println("Hello World!"+i);

        logger.info("Hello World!"+i);

        

        }

    }

}

Step 3:

Create log4j.properties file in src/main/resources

Add the build path points to src/main/resources


Top Section

  • No labels