Hi,

I used log4j earlier and setit up in my windows machine 2 years back.
Now I am using Opensuse. I wrote one class using eclipse.
I put log4j.jar and commons.logging in buildpath.
the class is like this

package log4jtest;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class LoggingTest {

        public static final Logger log = Logger.getLogger(LoggingTest.class);
        public static final String LOG_PROPERTIES_FILE =
"/home/ratnak/Work/Workspace/TestProject/resources/log4j.xml";

        public static void main(String[] args) {
        //      new LoggingTest();
                log.debug("This is debug statment");
                log.fatal("This is fatal error");
                log.info("This is information");
                System.out.println("Program finished running");
        }

        public LoggingTest() {
                initializeLogger();
                log.info("Log4JDemo - leaving the constructor ...");
        }

        private void initializeLogger() {
                Properties logProperties = new Properties();

                try {
                        logProperties.load(new 
FileInputStream(LOG_PROPERTIES_FILE));
                        PropertyConfigurator.configure(logProperties);
                        log.info("Logging initialized.");
                        System.out.println("Load Initialized");
                        System.out.println();
                } catch (IOException e) {
                        throw new RuntimeException("Unable to load logging 
property "
                                        + LOG_PROPERTIES_FILE);
                }
        }

}


Is there anything wrong inthat.
Every thing execut properly.
But I dont know why logging.log file is not getting generated.
Can you please tell me.

Thanks
RS.K
-- 
View this message in context: 
http://www.nabble.com/How-to-setup-Log4j-for-standalone-app-tp24253672p24253672.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to