public static Map < String , Object > toMap ( LoggingEvent e ) { final Map < String , Object > m = Objects . newHashMap ( "name" , e . getLoggerName ( ) , "date" , new Date ( e . getTimeStamp ( ) ) , "level" , e . getLevel ( ) . toString ( ) , "thread" , e . getThreadName ( ) , "message" , "" + e . getMessage ( ) , "fileName" , e . getLocationInformation ( ) . getFileName ( ) , "methodName" , e . getLocationInformation ( ) . getMethodName ( ) , "lineNumber" , e . getLocationInformation ( ) . getLineNumber ( ) , "requestId" , e . getMDC ( "requestId" ) , "sessionId" , e . getMDC ( "sessionId" ) , "freeMemory" , Runtime . getRuntime ( ) . freeMemory ( ) , "throwable" , null ) ; if ( e . getThrowableInformation ( ) != null && e . getThrowableInformation ( ) . getThrowable ( ) != null ) { Throwable t = e . getThrowableInformation ( ) . getThrowable ( ) ; m . put ( "throwable" , Objects . newHashMap ( "message" , t . getMessage ( ) , "class" , t . getClass ( ) . getName ( ) , "stackTrace" , getStackTrace ( t ) ) ) ; } return m ; }
Convert logging event to map