0

我收到以下错误:

1 error found:
File: C:\Users\adem\Desktop\various_topics\JavaProjects\log4jExample.java  [line: 15]
Error: cannot find symbol
  symbol:   method getLogger(java.lang.String)
  location: interface org.apache.logging.log4j.Logger

这是我的代码,基于本教程

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.*;

public class log4jExample{

  /* Get actual class name to be printed on */
  static Logger log = Logger.getLogger(log4jExample.class.getName());   //.getName()
  public static void main(String[] args)
    throws IOException,SQLException{

    log.debug("Hello this is an debug message");
    log.info("Hello this is an info message");
  }
}

谢谢!

4

1 回答 1

1

您需要导入:

import org.apache.log4j.Logger;

如果您使用的是 Maven,则可以使用以下依赖项:

<dependency>
   <groupId>log4j</groupId>
   <artifactId>log4j</artifactId>
   <version>1.2.15</version>
</dependency>
于 2013-05-02T23:10:48.877 回答