Questions tagged [mdc]

MDC (*mapped diagnostic context*) is a way to attach thread-scoped named identifier that can be added to every log message from that thread.

It is used to provide log messages with information that is unavailable to the scope when log is written.It provides the thread and user context to log messages and hence stamp each log for better tracking.

For example, it can help put Correlation Id to a request’s logs to help filter it out from similar logs at that time (from other quests) and also track it easily when this request hop from service to service by sharing the Correlation Id.

Typical use cases

Useful links

288 questions
0
votes
1 answer

How to determine if the request is NOT the initial request in a Filter?

What I am trying to do is the following: Modify the logback to write out the users id and request id on the log lines. e.g. 2017-11-24 [userid:abcd123 - requestId:12345679] [ClassA:MethodA1] message... 2017-11-24 [userid:abcd123 -…
edjm
  • 4,830
  • 7
  • 36
  • 65
0
votes
1 answer

mdc closes all nested dialogs instead of the active dialog

I try to open a mdc-dialog inside a mdc-dialog. When closing the second dialog, material-components-web closes both dialogs, instead of returning back to the underlying dialog (first dialog). See the example on codepen.io. Is that a bug or do I…
iocast
  • 98
  • 7
0
votes
1 answer

Sample Code for usage of BasicMDCAdapter class for java.util.logging framework

I am basically trying to add MDC support in java.util.logging framework without using any slf4j to JUL bridge alternative. In the Javadoc of BasicMDCAdapter it is mentioned that "Basic MDC implementation, which can be used with logging systems that…
codestreak
  • 149
  • 12
0
votes
1 answer

Has spring boot MDC inheritance behaviour changed?

Until recently I was using spring-boot 1.3.5.RELEASE and the following worked. @SpringBootApplication public class MyApplication { static { MDC.put("service_name", "myapp"); } public static void main(String[] args) { …
Rob H
  • 3
  • 4
0
votes
1 answer

Actor MDC context in aroundReceive method

I have a Java Akka application and I want to set a separate MDC context for each message handling based on information inside the message, for example I have the following base interface for all messages: public interface IdMessage { String…
erkfel
  • 1,588
  • 2
  • 17
  • 29
0
votes
1 answer

Set MDC value before any logging and retain until logging is completed

I have Logback configuration with SiftingAppender where dynamic MDC value is set on application load in main() method which is generated dynamically. How can I ensure that MDC value generated from Java code is loaded before all logging is started in…
t3rmin41
  • 668
  • 2
  • 8
  • 18
0
votes
0 answers

custom log statements using slf4j

I need to log statements something like below , in which the log statement consist of some custom values configured. I am using logging in context of spring batch. So i would like to differentiate log statements by the jobs running. Example job1 and…
0
votes
1 answer

Request ID not logged on moving to log4j 1.2's async-appender

I have a web application which has been logging synchronously using log4j1.2 so far. I am trying to move it to use the async-appender (from log4j 1.2). I have written an XML file - log4j.xml that initializes async-appender. However when I check the…
IM42
  • 138
  • 10
0
votes
1 answer

Is the log4j FileAppender thread-safe? Can I change the filename on the fly?

I run a Java webapp deployed in Tomcat. We use commons-logging as a wrapper around log4j v1.2.16 We have many concurrent requests hitting the server and do not wish to debug/trace log every request. However, for certain users we wish to trace their…
0
votes
1 answer

Can we use MDC for non logging purpose in JAVA

We have set User Item value in MDC class on Servlet, and getting item value in one common class. Using this logic, since we can't pass item value to common class due to some difficulties. Can anyone please suggest can we use MDC Log4J for non…
Siva KR
  • 11
  • 2
0
votes
0 answers

MDC on JBoss6 mixing session data

We have a very strange behaviour in JBoss 6.1 when using MDC. Our application is a SOAP web service and upon connection to the service we generate a unique transaction id that we set in the MDC for logging purpose. Now this works fine when I run the…
Pierre
  • 123
  • 1
  • 2
  • 9
0
votes
2 answers

Log4j Dynamic Parameter

i have a j2ee web application running on spring framework and using log4j for logging. I have this line in my log4j.properties file. this will insert the logs in my database. How do I set a dynamic value in the message part so that I can somehow…
cedric
  • 3,107
  • 15
  • 54
  • 65
0
votes
1 answer

How to pass session information to Axis2 handler

I have a middleware java spring application that publishes services on the top layer as well as has Axis 2 clients for service consumption on the bottom layer. When requests are made on the service layer a session ID is added to the thread context…
0
votes
1 answer

Setting Cedit Text

I have the following code in trying to set the text in a Cedit text box: class CMetaDlg : public CDialogEx { public: CMetaDlg(); // Dialog Data enum { IDD = IDD_META }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV…
user3396028
  • 37
  • 1
  • 9
0
votes
1 answer

Custom log4j appender

i wrote my personal log4j Daily Rolling Appender in order to customize the logging for my app. Here is the source code for the Appender private final static String DOT = "."; private final static String HIPHEN = "-"; private static final String…
1 2 3
19
20