Zhe Ma
Zhe Ma

Reputation: 45

java: cannot find symbol symbol: class getLogger location: class org.slf4j.LoggerFactory

I am learning Spring Boot and I have a strange problem.

import org.aspectj.lang.annotation.Aspect;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import org.slf4j.Logger;


@Aspect
@Component
public class HttpAspect {

    private final static Logger logger = new LoggerFactory.getLogger(com.zhe.demo.aspect.HttpAspect.class);


}

When I run the program,I got this:

  Error:(13, 59) java: cannot find symbol
  symbol:   class getLogger
  location: class org.slf4j.LoggerFactory

It seems that the getLogger() method cannot be resolved.

But I had imported package org.slf4j.LoggerFactory.I found static method getLogger() in the package.

Upvotes: 1

Views: 3483

Answers (3)

user16685820
user16685820

Reputation: 1

I had such problem yesterday. And solve it by pointing on slj4j library in moment resolve "logging" by IDE (in moment of red "logging"). You need to choice the write string from "logger resolve" list.

There is popular name "logger", so many libraries use it.

Upvotes: -1

SHN
SHN

Reputation: 171

Remove "new":

private final static Logger logger = new LoggerFactory.getLogger(com.zhe.demo.aspect.HttpAspect.class);

Upvotes: 4

Anant
Anant

Reputation: 1

It seems like a classpath problem. Do you have log4j jar in the classpath?

Upvotes: -1

Related Questions