Since version 2.0.0 Log4E is free now!

Log4E is a free Eclipse Plugin which helps you to use your logger easily in Java Projects.
The Plugin Log4E is not bound to any special logging framework. Thus you might be able to adapt to your own logger by defining your own templates using the preferences. It has active support for Log4j, Log4j 2, SLF4J, Commons Logging and JDK 1.4 logging.

See the Plugin in action (Screenshot)Download and Install it and start immediately.

Log4E replaces System.out.println, System.out.print, System.err.println, System.err.print and e.printStackTrace statements.
In the Preferences you can choose which logger level should be used.

Options:

  • Replace System.out
    If unchecked, the replacement of System.out's will be omitted.
  • Replace System.out with logger level
    Choose the level of logger.
  • Replace System.err
    If unchecked, the replacement of System.err's will be omitted.
  • Replace System.err with logger level
    Choose the level of logger.
  • Replace e.printStackTrace()
    If unchecked, the replacement of e.printStackTrace()'s will be omitted.
  • Replace e.printStackTrace() with logger level
    This setting is the same as Catch Block settings and is not configurable here.

Overview

The action "Exchange logging framework of this class" automatically changes the actual logging statements of the actual logging framework to the target logging framework. Both logging frameworks has to be defined in the templates (Preferences:Templates).

See the screenshots for a quick overview. 

Example:

Before:

import org.apache.log4j.Logger;
public String myMethod(String theString, int theInt) {
if (logger.isDebugEnabled()) {
logger.debug(
"myMethod(String theString="
+ theString
+ ", int theInt="
+ theInt
+ ") - my message");
}

//Your code....
try {
doSomethingVeryDangerous();
} catch (Exception myexception) {
logger.error("myMethod(String, int)", myexception);
}

return toString();
}
 

After exchanging to JDK1.4 logging (logp):

import java.util.logging.Level;
import java.util.logging.Logger;

public String myMethod(String theString, int theInt) {
	if (logger.isLoggable(Level.CONFIG)) {
logger.logp(
Level.CONFIG,
"MyClass",
"myMethod(String theString="
+ theString
+ ", int theInt="
+ theInt
+ ")",
"my message");
}

//Your code....
try {
doSomethingVeryDangerous();
} catch (Exception myexception) {
logger.logp(Level.SEVERE, "MyClass", "myMethod(String, int)",
"", myexception);
}

return toString();
}

 

Joomla templates by a4joomla