0

path有人能告诉我在哪里以及如何设置Netbeans吗?我想添加一个 .properties 文件

我有没有看到 log4j.properties 文件的 log4j 示例项目:

log4j:WARN No appenders could be found for logger (log4j_lesson.log4jExample).
log4j:WARN Please initialize the log4j system properly.

主类:

import org.apache.log4j.Logger;

import java.io.*;
import java.sql.SQLException;
import java.util.*;

public class log4jExample{
  /* Get actual class name to be printed on */
  static Logger log = Logger.getLogger(
                      log4jExample.class.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

通过右键单击项目,选择“属性”然后选择“运行”,添加-Djava.library.path=/path/to/properties/file到您在 Netbeans 中的“VM 选项”。

或者,将属性文件添加到项目的基本目录中,log4j 会自动查看它们。

于 2013-10-08T11:11:48.530 回答