Skip to content
Advertisement

unable to write the logs to log file using log4j through Gradle

I am working on Cucumber TestNg Gradle automation project. As I am new to Gradle and not able to figure the issue though I have put in appropriate log4j dependencies in build.gradle file. Can somebody look into this issue and provide the solutions or advise me on what went wrong due to which logs are not written to log file called “ApplicationLogs.log”

Below is my project structure

enter image description here

Below is my Log4j.properties file contents

Root logger option

JavaScript

Below is my build.gradle File Contents

JavaScript

Advertisement

Answer

I found the issue.

The problem was that you didn’t use the LoggerHelper.

This is my project structure :

enter image description here

Updated LoggerHelper class :

enter image description here

To test whether LoggerHelper is working or not. I added one Test class with main method :

enter image description here

Console :

enter image description here

The log generated file.

enter image description here

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement