File Logging : How to configure log4j to write logs in a file programmatically
package com.techfundaes.log4j; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; public class FileNameCustomized { public static void main(String[] args) { PropertyConfigurator.configure("resources/myLog4j.properties"); Logger logger = Logger.getLogger(FileNameCustomized.class); logger.info("Whoa..it works !"); } }