package me.allenz.androidapplog;

import java.lang.Thread.UncaughtExceptionHandler;

public class UncaughtExceptionLogger implements UncaughtExceptionHandler {

	private UncaughtExceptionHandler mDefaultExceptionHandler;

	public UncaughtExceptionLogger() {
		this(Thread.getDefaultUncaughtExceptionHandler());

	}

	public UncaughtExceptionLogger(
			final UncaughtExceptionHandler uncaughtExceptionHandler) {
		this.mDefaultExceptionHandler = uncaughtExceptionHandler;
	}

	@Override
	public void uncaughtException(final Thread thread, final Throwable ex) {
		final Logger logger = LoggerFactory.getLogger(ex.getStackTrace()[0]
				.getClassName());
		logger.error(ex);
		if (mDefaultExceptionHandler != null) {
			mDefaultExceptionHandler.uncaughtException(thread, ex);
		}
	}

	public UncaughtExceptionHandler getDefaultExceptionHandler() {
		return mDefaultExceptionHandler;
	}

}

@@ -662,16 +662,77 @@
 error(ex
+, %22Uncaught exception in thread %5B%25s%5D :%22,%0A%09%09%09%09thread.getName()
 );%0A%09%09if 

print line 'Uncaught exception in thread [%threadName]' before printing the message of uncaught exception