Nonesole.com > Easywork > EasyLog

EasyLog Project

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.

Users can choose to use EasyLog as an Open Source/Free Software product under the terms of the GNU General Public License.

1. Public Version

  • V1.01 released in 2011-03

2. Source and Download

3. API Document

4. Example

Some key points include:

1) Config introduction

printTestInfo=true/fasle : When users execute jar file,system whether or not prints test information on console.
isDebug=true/fasle : If 'isDebug' is true,system must record any information into debug log file whatever the log type is.
isDetail=true/fasle : Except 'debug' log file,users can decide whether or not to record detail information of exception into 'info' , 'warn' , 'error' , and 'fatal' log file.If 'isDetail' is true,the exception would be record into these files.
isSimpleFormat=true/fasle : If 'isSimpleFormat' is true,system just need record date and description.
envLogPath=EASY_LOG : The root folder of EasyLog is System.getProperty("user.dir") + prop.get("envLogPath").

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
Debug log
Info log
Warn log
Error log
Fatal log


Copyright (C) 2009-2011 NoneSole.com