user2472968
user2472968

Reputation: 405

log4j 1.2 configuration issue with Spring mvc

I am stuck. I have a configuration issue in setting up log4j with Spring MVC. Getting the below error.

log4j:WARN No appenders could be found for logger (org.springframework.web.servlet.DispatcherServlet).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Here is my controller code

     public class HelloWorldController {

private static Logger logger = Logger.getLogger(HelloWorldController.class);

int first_no=10;
int second_no=10;
int summation;
@RequestMapping("/helloworld")
   public String helloWord(ModelMap modelview){

    summation=first_no+second_no;

    System.out.println("Inside hello world");


    logger.info("Hello, World!");
      modelview.addAttribute("message", summation);

         return "helloworld";
    }
}

Here is my log4j.properties file

    # Direct log messages to stdout
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.Target=System.out
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

   # Root logger option
   log4j.rootLogger=debug, file, stdout

I have kept the file under src/resources in eclipse. Can anyone help me out with this? I am stuck.

Upvotes: 1

Views: 746

Answers (1)

AllTooSir
AllTooSir

Reputation: 49432

Probably log4j.properties file is not in the classpath.Move the log4j.properties in src folder in Eclipse and under WEB-INF/classes when deployed in the Container.

Upvotes: 1

Related Questions