Q: Is it possible to read the output from ConsoleAppender on a mobile phone.

A: On some mobile phones, such as SonyEricsson P800/P9xx, it is possible to install an application the redirects the output from System.out & System.err. One such application is the Redirector. More info can be found in the "Tips & Tricks" section.

Q: Why should I use the Microlog package?

A: See the "Features/benefits" section.


Q: How do I setup the PatternFormatter in my microlog.properties file?

A: You use the microlog.formatter.PatternFormatter.pattern property to set the pattern for the PatternFormatter.

Example: # Set the pattern for the PatternFormatter microlog.formatter.PatternFormatter.pattern=%r %c %m %T

This would print the relative logging time, the name of the Logger, the logged message and the Throwable object (if not null).

The available pattern conversions are: %c : prints the name of the Logger %m : prints the logged message %P : prints the priority, i.e. Level of the message. %r : prints the relative time of the logging. (The first logging is done at time 0.) %t : prints the thread name. %T : prints the Throwable object. %% : prints the '%' sign.


Q: How do I remove the code when releasing my code.

A: There are a number of ways to solve this:

1. Check if debug is enabled.

if(log.isDebugEnabled()) log.debug("Value x is "+x);

This will avoid creating the combined String object, and thus avoiding object creation. The call to log.debug() will never be done, which also saves some time.

2. Checking a static final variable

public static final boolean LOG_ENABLED = true;

if(LOG_ENABLED) log.debug("Value x is "+x);

If the LOG_ENABLED is set to false, the code will be removed as dead code. This will save both time & space.

3. Using a pre-processor, for example the ProGuard pre-processor.

//#ifdef LOG_ENABLED log.debug("A log message"); //#endif

This will make it possible to remove all the logging code when desired.

4. Using AspectME.

See the AspectME documentation on how to write an aspect that does the logging for you.

This method injects the logging code when needed. If you to disable logging, no extra code is added to your application.