在主函数加上这个static块就可以了。

static {
	PropertyConfigurator.configure(
		System.getProperty("user.dir") 
		+ File.separator + "conf"
		+ File.separator + "log4j.properties");
}