1

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.

4

1 回答 1

0

如果您对安全性的关注是并发性,那么我会说您的信息是完全安全的。作为参考,您可以查看logback 网站

A copy of the mapped diagnostic context can not always be inherited by worker threads from the initiating thread. This is the case when java.util.concurrent.Executors is used for thread management. For instance, newCachedThreadPool method creates a ThreadPoolExecutor and like other thread pooling code, it has intricate thread creation logic.

我们在处理请求时将值放在 MDC 中(通常在 J2EE 应用程序的情况下放在 ServletFilter 中),并且我们总是在请求处理即将完成时删除这些值。

于 2013-08-05T13:32:25.490 回答