我收到以下错误:
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
这是我的代码,基于此tutorial:
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");
}
}
谢谢!
答案 0 :(得分:2)
您需要导入:
import org.apache.log4j.Logger;
如果您正在使用Maven,则可以使用以下依赖项:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>