EasyLog Introduction EasyLog is a part of Easy-work project,but it can be used alone in any works.Users can use it to manage runtime information of software,like errors , exceptions and so on. Some key points include: 1. Config introduction
printTestInfo=true/fasle : When users execute jar file,system whether or not prints test information on console. 2. Use it in coding
Full log : new Logger() .clear() //If users use only one Logger object to record various information,this method must be used. .newWarn() .setSimpleFormat(false) //Overwrite default config which is from config file. .setUser("tom") //Not necessary .setSource("login.jsp") //Not necessary .setCategory("system") //Not necessary .setData("User name : tom . password : xxxxx ") //Not necessary .setDescription("Login error.") //Not necessary .write(new Exception("Password is empty.")); //Or use like this : '.write()';
Simple log new Logger() .clear() .newWarn() .setSimpleFormat(true) //It is not necessary if 'isSimpleFormat' is true in config file. .setDescription("User Jeff is online.") .write();
Read log List<LogData> l = LogReader.getInstance().read(new LogDataFilter(){ public boolean match(LogData data) { return true; } }, "warn", new Date()); for ( LogData ld : l ) System.out.println(ld.toString()); 3. Source & Result
EasyLogDemo.java |