|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Issue with using NDC (nested diagnostic contexts)Hi,
I am using NDC (nested diagnostic contexts) for appending the text from a specific thread.
Using floowing code:
-------------------------
//In side the run method of that thread
log4cxx::NDC::push("Thread specific Info");
printing some log4cxx messages.......
//Just before exiting the thread
log4cxx::NDC::pop();
-------------------------------
But the issue is I am not able to get the "Thread specific Info" message in any of the messages I am printing in that thread.
I am using log4cxx 0.10.0 version.
Please let me know if you have any idea.
Thanks
Deepak
|
|
|
Re: Issue with using NDC (nested diagnostic contexts)What format pattern are you using?
On Mon, Jun 15, 2009 at 3:11 PM, deepak singh <deepak.iitg@...> wrote:
|
|
|
Re: Issue with using NDC (nested diagnostic contexts)I am using following format.
//log4cxx initialization
log4cxx::LogManager::resetConfiguration(); log4cxx::LayoutPtr layoutPtr(new log4cxx::PatternLayout("%c-%p (%d{dd MMM yyyy HH:mm:ss}) [%-5t] %m%n")); log4cxx::AppenderPtr appenderPtr( new log4cxx::ConsoleAppender(layoutPtr, "System.err")); log4cxx::BasicConfigurator::configure(appenderPtr); Thanks
Deepak
On Mon, Jun 15, 2009 at 5:43 PM, Assaf Lavie <assaflavie@...> wrote:
|
|
|
Re: Issue with using NDC (nested diagnostic contexts)On 2009-06-15 06:16, deepak singh wrote:
> On Mon, Jun 15, 2009 at 5:43 PM, Assaf Lavie <assaflavie@...> wrote: >> On Mon, Jun 15, 2009 at 3:11 PM, deepak singh <deepak.iitg@...>wrote: >>> I am using NDC (*nested diagnostic contexts*) for appending the text >>> from a specific thread. >>> But the issue is I am not able to get the "Thread specific Info" message >>> in any of the messages I am printing in that thread. >>> >> What format pattern are you using? >> > log4cxx::LayoutPtr layoutPtr(new log4cxx::PatternLayout("%c-%p (%d{dd MMM > yyyy HH:mm:ss}) [%-5t] %m%n")); Your pattern layout does not include the conversion character to indicate where you want your NDC stack to be inserted: x - Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event. (From the PatternLayout documentation.) "%c-%p (%d{dd MMM yyyy HH:mm:ss}) [%-5t] %x %m%n" That change should fix your output issue and then you can start playing more with placement (or use at all) of the NDC::push/NDC::pop methods and see where they work best for you. I prefer to use the constructor to set the value and let stack scope take care of the pop. -- Jacob Anawalt Gecko Software, Inc. janawalt@... 435-752-8026 |
| Free embeddable forum powered by Nabble | Forum Help |