Apache Giraph的日志(log4j)位于项目的log4j.properties文件中。您可以在项目根目录下的src/main/resources目录中找到该文件。以下是一个示例代码,展示如何配置log4j.properties文件:
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
public class ExampleClass {
private static final Logger LOGGER = Logger.getLogger(ExampleClass.class);
public static void main(String[] args) {
// 配置log4j.properties文件
PropertyConfigurator.configure("path/to/log4j.properties");
// 使用日志记录器
LOGGER.debug("This is a debug message");
LOGGER.info("This is an info message");
LOGGER.warn("This is a warning message");
LOGGER.error("This is an error message");
}
}
在上面的示例中,我们首先使用PropertyConfigurator.configure()方法来加载log4j.properties文件。然后,我们可以使用Logger.getLogger()方法获取日志记录器,并使用该记录器记录不同级别的日志消息。