1NDC(3)                User Contributed Perl Documentation               NDC(3)
2
3
4

NAME

6       Log::Log4perl::NDC - Nested Diagnostic Context
7

DESCRIPTION

9       Log::Log4perl allows loggers to maintain global thread-specific data,
10       called the Nested Diagnostic Context (NDC).
11
12       At some point, the application might decide to push a piece of data
13       onto the NDC stack, which other parts of the application might want to
14       reuse. For example, at the beginning of a web request in a server, the
15       application might decide to push the IP address of the client onto the
16       stack to provide it for other loggers down the road without having to
17       pass the data from function to function.
18
19       The Log::Log4perl::Layout::PatternLayout class even provides the handy
20       %x placeholder which is replaced by the blank-separated list of
21       elements currently on the stack.
22
23       This module maintains a simple stack which you can push data on to,
24       query what's on top, pop it off again or delete the entire stack.
25
26       Its purpose is to provide a thread-specific context which all
27       Log::Log4perl loggers can refer to without the application having to
28       pass around the context data between its functions.
29
30       Since in 5.8.0 perl's threads don't share data only upon request,
31       global data is by definition thread-specific.
32
33       Log::Log4perl::NDC->push($text);
34           Push an item onto the stack. If the stack grows beyond the defined
35           limit ($Log::Log4perl::NDC::MAX_SIZE), just the topmost element
36           will be replated.
37
38           This is typically done when a context is entered.
39
40       Log::Log4perl::NDC->pop();
41           Discard the upmost element of the stack. This is typically done
42           when a context is left.
43
44       my $text = Log::Log4perl::NDC->get();
45           Retrieve the content of the stack as a string of blank-separated
46           values without disrupting the stack structure. Typically done by
47           %x.  If the stack is empty the value "[undef]" is being returned.
48
49       Log::Log4perl::NDC->remove();
50           Reset the stack, remove all items.
51
52       Please note that all of the methods above are class methods, there's no
53       instances of this class.
54
56       Copyright 2002-2009 by Mike Schilli <m@perlmeister.com> and Kevin Goess
57       <cpan@goess.org>.
58
59       This library is free software; you can redistribute it and/or modify it
60       under the same terms as Perl itself.
61
62
63
64perl v5.12.2                      2010-08-31                            NDC(3)
Impressum