1MDC(3) User Contributed Perl Documentation MDC(3)
2
3
4
6 Log::Log4perl::MDC - Mapped Diagnostic Context
7
9 Log::Log4perl allows loggers to maintain global thread-specific data,
10 called the Nested Diagnostic Context (NDC) and Mapped Diagnostic
11 Context (MDC).
12
13 The MDC is a simple thread-specific hash table, in which the
14 application can stuff values under certain keys and retrieve them later
15 via the "%X{key}" placeholder in
16 "Log::Log4perl::Layout::PatternLayout"s.
17
18 Log::Log4perl::MDC->put($key, $value);
19 Store a value $value under key $key in the map.
20
21 my $value = Log::Log4perl::MDC->get($key);
22 Retrieve the content of the map under the specified key. Typically
23 done by %X{key} in "Log::Log4perl::Layout::PatternLayout". If no
24 value exists to the given key, "undef" is returned.
25
26 my $text = Log::Log4perl::MDC->remove();
27 Delete all entries from the map.
28
29 Log::Log4perl::MDC->get_context();
30 Returns a reference to the hash table.
31
32 Please note that all of the methods above are class methods, there's no
33 instances of this class. Since the thread model in perl 5.8.0 is "no
34 shared data unless explicitly requested" the data structures used are
35 just global (and therefore thread-specific).
36
38 Copyright 2002-2013 by Mike Schilli <m@perlmeister.com> and Kevin Goess
39 <cpan@goess.org>.
40
41 This library is free software; you can redistribute it and/or modify it
42 under the same terms as Perl itself.
43
45 Please contribute patches to the project on Github:
46
47 http://github.com/mschilli/log4perl
48
49 Send bug reports or requests for enhancements to the authors via our
50
51 MAILING LIST (questions, bug reports, suggestions/patches):
52 log4perl-devel@lists.sourceforge.net
53
54 Authors (please contact them via the list above, not directly): Mike
55 Schilli <m@perlmeister.com>, Kevin Goess <cpan@goess.org>
56
57 Contributors (in alphabetical order): Ateeq Altaf, Cory Bennett, Jens
58 Berthold, Jeremy Bopp, Hutton Davidson, Chris R. Donnelly, Matisse
59 Enzer, Hugh Esco, Anthony Foiani, James FitzGibbon, Carl Franks, Dennis
60 Gregorovic, Andy Grundman, Paul Harrington, Alexander Hartmaier David
61 Hull, Robert Jacobson, Jason Kohles, Jeff Macdonald, Markus Peter,
62 Brett Rann, Peter Rabbitson, Erik Selberg, Aaron Straup Cope, Lars
63 Thegler, David Viner, Mac Yang.
64
65
66
67perl v5.38.0 2023-07-20 MDC(3)