简体   繁体   English

无法在 Java 中导入 log4j 类

[英]Not able to import log4j classes in Java

I am getting started with log4j and i am stuck at the very first point which is to import the classes successfully and to make it run.我开始使用 log4j 并且我被困在第一点,即成功导入类并使其运行。

I have already added the external jars for log4j 1.2 api -2.14.1 But i am unable to import the classes.我已经为 log4j 1.2 api -2.14.1 添加了外部 jars 但我无法导入这些类。

This is my code with all the jars i have imported这是我导入的所有 jars 的代码

This is the exception i am getting after running the code这是我运行代码后遇到的异常

Edit: So i did a bit of digging myself and sorted the above error by the below steps:编辑:所以我做了一些挖掘自己并通过以下步骤对上述错误进行排序:

  1. Go to your project properties by right clicking on it.通过右键单击 Go 到您的项目属性。
  2. Go to "Java Build Path". Go 到“Java 构建路径”。
  3. Go to Libraries and Select JRE Go 到库和 Select JRE
  4. Edit and Set Exxeecution Environment to JRE 1.1将执行环境编辑并设置为 JRE 1.1

I see you have log4j-api but you also need log4j-core installed as well.我看到你有 log4j-api 但你也需要安装 log4j-core。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM