java - Pass log event specific data with slf4j (and log4j) -


is there way pass further information applies current log event slf4j? request based information user, ip address or application name can stored , accessed via mdc. later can access information in layout or converter , dont have parse log message. if use json based format have field "appname":myapp , if log log4j in plaint text can access via %{appname} notation. there way achieve information applies 1 log event? example want pass exception id(even exceptions not own). best still ugly solution pass id mdc, log exception , delete afterwards. does know better solution?

if don't need use slf4j , log4j enough - can use custom messages log4j: https://logging.apache.org/log4j/2.x/manual/messages.html

if want slf4j - implement own logger adapter treat parameters appropriately (just http://www.slf4j.org/xref/org/slf4j/impl/jdk14loggeradapter.html)


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -