Code Replacement

Log4E replaces System.out.println, System.out.print, System.err.println, System.err.print and e.printStackTrace statements.

Most of the documentation is already done in the Preferences.

Here's an example:

Before:

public void myMethod() {
	System.out.println("method start");
	
	try {
		System.out.println("trying something very dangerous...");
		//Your code...
	} catch (OutOfCheeseError ex) {
		System.err.println("redo from start...");
		ex.printStackTrace();
	}
	
	// silly example to show what happens outside a catch block
	if (false) {
		System.err.println("Should never reach this code");
	}
	
	System.out.println("end of method");
}

After:

public void myMethod() {
	if (logger.isDebugEnabled()) {
		logger.debug("myMethod() - method start");
	}
	
	try {
		if (logger.isDebugEnabled()) {
			logger.debug("myMethod() - trying something very dangerous...");
		}
		//Your code...
	} catch (OutOfCheeseError ex) {
		logger.error("myMethod() - redo from start...", ex);
		logger.error("myMethod()", ex);
	}
	
	// silly example to show what happens outside a catch block
	if (false) {
		logger.error("myMethod() - Should never reach this code", null);
	}
	
	if (logger.isDebugEnabled()) {
		logger.debug("myMethod() - end of method");
	}
}



http://log4e.jayefem.de