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
1
vote
1 answer

How to pass log file name through MDC logback feature

I would like to use logback MDC feature for my log name, but I get %PARSER_ERROR[X] in file name. Maybe it is impossible to assign the name for log file. In my log file pattern parameter is passed without problems. Any help would be…
elkoo
  • 704
  • 9
  • 23
1
vote
1 answer

using log4net and IHttpModule with a WCF service

I have a Website that contains a number of webpages and some WCF services. I have a logging IHttpModule which subscribes to PreRequestHandlerExecute and sets a number of log4net MDC variables such as: MDC.Set("path",…
Aaron0
  • 389
  • 4
  • 14
1
vote
1 answer

Log4J conversion specifier "%l" not printing the whole stack trace

I am trying to send an email in case error occurs in our project. For this we are using Log4j's SMTPAppender. I am running my project in the development mode and trying to get the full stack trace of the error by using following ConversionPattern in…
Ram Dutt Shukla
  • 1,351
  • 7
  • 28
  • 55
1
vote
0 answers

log4j: Bubble up error/exception details

My team is using slf4j for logging purposes and are looking at logging errors/exception situations at the top of the hierarchy in the class (For ex: Class A-> Class B-> Class C(exception here) === log in Class A method). It'd be good if we could…
user1071840
  • 3,522
  • 9
  • 48
  • 74
1
vote
1 answer

Can log4j MDC be used for non-threaded application?

I have a scenario wherein I invoke a third party REST URL from inside a FOR loop for different values of the field JOBNAME. I wish to log the logging statements for each JOBNAME inside a separate log file i.e. the request sent to the REST URL, all…
1
vote
1 answer

Use Mapped Diagnostic Context (MDC) for passing colum values to log4j prepared statement

Is it safe to Use MDC to pass column values and xmls dynamically to a preparedstatement in log4j.xml. If yes, then how and when can i clear it to avoid memory leaks. FYI - many threads are going to use my log4j simultaneously.
user837593
  • 337
  • 1
  • 5
  • 25
1
vote
2 answers

Log Viewer - MDC Support

I'm trying to find a log viewer for a log4j generated plain text file that supports MDC. I have looked at a few like Chainsaw, LogSaw, Otros but they seem to only support NDC. Can anyone point me in the right direction?
NathanS
  • 163
  • 2
  • 10
1
vote
1 answer

log4j logging based on device MAC/IP

I have a Java API library. The library intended to test functionalities of a device. Later these libraries are exposed as webservices so that non-java programs can also access it. I have a single EAR which contains the beans and dependent libraries…
appu
  • 538
  • 10
  • 24
0
votes
1 answer

Logging username in log4j

I need to print username and client IP address in logs.but username is only prints for first thread using MDC in log4j.From next thread the values are printed as empty. can any one suggest how to proceed further on this .
Kannan C
  • 1
  • 1
  • 1
0
votes
0 answers

How to read the request id from http request header and delegate it to (all) http clients in a spring boot app

Reading of the incoming HTTP Requests with the request id is done by a jakarta.servlet.Filter. @Component class MdcFilter : Filter { private val log = KotlinLogging.logger {} override fun doFilter(request: ServletRequest?, response:…
nusmanov
  • 451
  • 4
  • 15
0
votes
0 answers

Custom AnnotationAspect doesnt get called

I am trying to implement a Custommade annotation that contains a value as a parameter and when the annotation is used, this value should be processed with a MDC.put. So when I use a method with the annotation @Usecase("TestUsecase"),…
0
votes
0 answers

MDC content is not printed via log4j2-jboss-logmanager on quarkus

I want to put a content into "org.jboss.logging.MDC" and make available in logging via log4j2, but value is not showable only for log4j2. I also tried "java.util.logging.Logger" and "org.jboss.logging.Logger". These can show MDC content fine in…
C. Bilgin
  • 65
  • 6
0
votes
0 answers

MDC value getting cleared - zipwih method

I have a weird situation. I'm using webflux+MDC for logging. My method does fetch a flux from db and then zips it with the another value from another table. Now with this, the MDC is correctly propogated and I can see that in logs also. But if I run…
AD90
  • 179
  • 2
  • 2
  • 9
0
votes
0 answers

how to create a theme with a custom color in angular?

All the examples I've come across use a pre-existing palette, like $indigo-palette. For example here: https://material.angular.io/guide/theming I don't want to use any indigo, pink or any pre-defined palette. I want to create a theme with my custom…
Ya.
  • 1,671
  • 4
  • 27
  • 53
0
votes
1 answer

How to log request and response body in WebFlux using MDC + Logbook

I have a Spring Boot application, a reactive service which calls external systems via WebClient. I also have some non-reactive services. There is already implemented logging using MDC + Logbook for Feign clients. It's highly desirable to reuse…
stakeika
  • 55
  • 1
  • 8