I'm using following pattern:
- My Log4j pattern is using MDC - %d{ISO8601} %p [%X{REQUEST_ID}][%X{SESSION_ID}][%X{USER}] %class %m%n
In application for every request I'm using MDC.put() method to set REQUEST_ID, SESSION_ID, USER
MDC.put("SESSIONION_ID", sessionId); MDC.put("REQUEST_ID", requestId); MDC.put("USER", user);
I have defined this log pattern in OtrosLogViewer. Your log pattern definition should looks like:
type=log4j pattern=TIMESTAMP LEVEL [PROP(REQUEST_ID)][PROP(SESSION_ID)][PROP(USER)] CLASS MESSAGE dateFormat=yyyy-MM-dd HH:mm:ss,SSS name="MyAppLog" charset=UTF-8
I open logs with OtrosLogViewer which allows me to easy filter by property REQUEST_ID, SESSIONS_ID or USER_ID. It can also filter logs by class, date, thread, etc. Logs can be open from remote servers using SFTP, FTP, SMB
Additionally you can integrate OtrosLogViewer with your Intellij. See example on Youtube: https://www.youtube.com/watch?v=SbOFF56_7-A?hd=1
Disclaimer: I am the author of OtrosLogViewer