Java tutorial
//package com.java2s; public class Main { public static final String SEPARATOR = ","; public static String getLogInfo(StackTraceElement stackTraceElement) { StringBuilder logInfoStringBuilder = new StringBuilder(); String threadName = Thread.currentThread().getName(); long threadID = Thread.currentThread().getId(); String fileName = stackTraceElement.getFileName(); String className = stackTraceElement.getClassName(); String methodName = stackTraceElement.getMethodName(); int lineNumber = stackTraceElement.getLineNumber(); logInfoStringBuilder.append("[ "); logInfoStringBuilder.append("threadID=" + threadID).append(SEPARATOR); logInfoStringBuilder.append("threadName=" + threadName).append(SEPARATOR); logInfoStringBuilder.append("fileName=" + fileName).append(SEPARATOR); logInfoStringBuilder.append("className=" + className).append(SEPARATOR); logInfoStringBuilder.append("methodName=" + methodName).append(SEPARATOR); logInfoStringBuilder.append("lineNumber=" + lineNumber); logInfoStringBuilder.append(" ] "); return logInfoStringBuilder.toString(); } }