Search code examples
javanetbeanslog4j

log4j with netbeans (loggin to a file)


i am trying to setup log4j to my java web application based on Maven on Netbeans 12.6 , And i am following this video: enter link description here in this tutorial the logging will be writing into a file.

But in my case after running the application no log file created

  1. This is my Netbeans setup: enter image description here

    I will appreciate all your answers


Solution

  • ALL PROBLEMS SOLVED! For Log4J logging to a file on Netbeans

    Step 1: Import log4j-1.2.17.jar library to your project
    enter image description here

    Step 2: First we need to move the log4.properties to a separate directory that we need to create by our self with the name "src/test/resources". For that, Right click on your main project in my case is "Log4Shell" --> then from the categories choose "Other" --> then chose "Properties File" --> then gave it a name "src/test/resources". enter image description here

    Step 3: create a new file properties: Right Click on --> new --> Properties File --> File Name:log4j.properties enter image description here

    Step 4: we need to create a javaclass under the Test Package repository enter image description here

    Step 5: Time for test: Right click on "NewClass.java"-->Debug Test File. Result OK: enter image description here