views:

644

answers:

1

When I run the TestJcLLoggingService class log messages are coming to Console but no log file is created, please help me if you know the answer.

two source files are pasted below.

TestJcLLoggingService.java

package com.amadeus.psp.pasd.logging;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;

@Service
public class TestJCLLoggingService {
    private static Log psp_log = LogFactory.getLog(TestJCLLoggingService.class);
    public static String testJCLLoggingServiceMethod(){
     psp_log.info("start of method testJCLLoggingServiceMethod class TestJCLLoggingService");

     psp_log.info("start of method testJCLLoggingServiceMethod class TestJCLLoggingService");
     return "This is a test string for JCLLogging";

    }

    public static void main(String[] args){

     testJCLLoggingServiceMethod();

    }

}

logging.properties

handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
.level = ALL
com.amadeus.psp.pasd.level=ALL
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter


java.util.logging.FileHandler.pattern = %h/java%u.log 
java.util.logging.FileHandler.level=ALL
java.util.logging.FileHandler.limit=50000
java.util.logging.FileHandler.count=1
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.append=true

Thanks in advance.

A: 

Your question is answered in a related thread : Java util logging

Basically you need to set the path of the configuration file (logging.properties) either in java args or in code itself and then look in the right folder. (Default is user home)

techzen