回忆:日志文件的重写
?
哎...纯粹就是找点代码做
import org.apache.log4j.Level;import org.apache.log4j.Logger;public class SysLogger {//static{//PropertyConfigurator.configure("./config/log4j.properties");//}private static final String module = SysLogger.class.getName();public static void debug(String debugStr) {Logger log = Logger.getLogger("debug");log.log(module, Level.DEBUG, debugStr, null);}public static void info(String infoStr) {Logger log = Logger.getLogger("info");log.log(module, Level.INFO, infoStr, null);}public static void warn(String warnStr) {Logger log = Logger.getLogger("warn");log.log(module, Level.WARN, warnStr, null);}public static void error(String errStr, Throwable e) {Logger log = Logger.getLogger("error");log.log(module, Level.ERROR, errStr, e);}public static void error(String errStr) {Logger log = Logger.getLogger("error");log.log(module, Level.ERROR, errStr, null);}
??
接着是读取 配置文件(load 一个输入流就好了)
InputStream in = *.getResourceAsStream("mongodb.properties");Properties prop = new Properties(); prop.load(in);String host = prop.getProperty("host").trim();
?