tag:blogger.com,1999:blog-6643071316318130698.post2800954192214461878..comments2023-06-24T02:38:55.310-07:00Comments on Frank Kieviet's Engineering Notebook: Using Nested Diagnostics Contexts in Glassfishfkieviethttp://www.blogger.com/profile/07479805042474878714noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-6643071316318130698.post-69939399276737207292012-03-13T21:08:42.003-07:002012-03-13T21:08:42.003-07:00This is a nice feature in Glassfish - and is parti...This is a nice feature in Glassfish - and is particularly useful with the JBI BPEL Service Engine. <br><br>There is a problem with this code when glassfish runs on JDK1.6.0_18 (that is not present with at least JDK1.6.0_11 or earlier). The java.util.logging.LogManager now maintains weak references to its loggers (including the NDCEntryLogger and NDCExitLogger). And so these are garbage collected by the container.<br><br>If the NDCProvider code is changed to declare the NDCLogger references as static this stops them from being garbage collected.<br><br>Brent Haighnullnoreply@blogger.comtag:blogger.com,1999:blog-6643071316318130698.post-33399730065900356802012-03-13T21:08:42.002-07:002012-03-13T21:08:42.002-07:00An update: see http://frankkieviet.blogspot.com/20...An update: see <a href="http://frankkieviet.blogspot.com/2009/09/lessons-of-interesting-deadlock-problem.html" rel="nofollow">http://frankkieviet.blogspot.com/2009/09/lessons-of-interesting-deadlock-problem.html</a><br><br>Frank Kievietnullnoreply@blogger.comtag:blogger.com,1999:blog-6643071316318130698.post-84239926947050371792012-03-13T21:08:42.001-07:002012-03-13T21:08:42.001-07:00Re Rajan:Correct, the NDC requires push and pop. T...Re Rajan:<br><br>Correct, the NDC requires push and pop. Through that, a thread can go from module to module and maintain a debugging context.<br><br>Although the MDC certainly has its merits, going through multiple modules may be confusing because values are overwritten. And if values are not removed, they may confusion in subsequent calls, especially if threads can be dispatched to different applications.<br><br>Nevertheless, the same approach as described in this blog entry can be used to hookup an MDC in the jdk logging package.<br><br>Frank<br><br>Frank Kieviethttp://blogs.sun.com/fkievietnoreply@blogger.comtag:blogger.com,1999:blog-6643071316318130698.post-91360220989612035992012-03-13T21:08:42.000-07:002012-03-13T21:08:42.000-07:00In my opinion, Maped Diagnostic Context (MDC) is b...In my opinion, Maped Diagnostic Context (MDC) is better than NDC. I may be wrong but NDC requires push and pop..If a developer forgets to pop then it may cause some memory leaks. MDC how ever useds maps.<br><br>Rajan Jainnullnoreply@blogger.com