Couldn't this problem be solved by making this (serialization) behavior configurable. Moving the serialization logic out of LoggingEvent and into a strategy class. The default behavior could be identical to existing code. Alternate strategy impls could be written to do other interesting things, like deep MDC copy, and retention of the original un-rendered log message, etc...
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, January 30, 2004 1:42 PM To: [EMAIL PROTECTED] Subject: RE: MDC copies None of the changes I have made should add any serious performance overhead. Old behavior: MDC.put("name", "value"); (get is similar) - get thread local map - get value from tlm - if value is null - new Hashtable - put new hashtable in tlm - hashtable.put("name", "value"); New behavior: - get thread local map - get value from tlm - if value is null - getFactory (singleton) - factory.create (just calls new BasicMDCContainer which is just a subclass of hashtable) - put new container in tlm - container.put("name", "value"); (Logger is not affected) No other code is run unless you use async appender, and that just calls clone on the container (delegates to the parent hashtable) by default. I think maybe my explanation was unclear. This is a very low overhead change. Should I just send it for folks to look at? -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, January 30, 2004 4:03 PM To: Log4J Developers List Subject: RE: MDC copies Christian, Adding functionality with computational overhead which is only used with AsyncAppender, does not make sense to me. AsyncAppender is there for performance reasons. Logging asynchronously should not be much slower than direct logging. Unless I am missing something, I think the changes you propose will be counterproductive. At 08:08 AM 1/30/2004 -0500, [EMAIL PROTECTED] wrote: >I have completed the modifications to support a pluggable MDC >container. It consists of four new files and patches to ThreadLocalMap, >MDC and LoggingEvent. > >The Web site is not clear on coding conventions or how to send new >files (it talks about diff, but I have multiple files...do I just post >a huge diff?). I am finishing testing today and will be ready to >contribute. Can someone tell me how best to send? > >-Christian > > >A summary of the design: > >Two new plug points have been added: >- MDCContainer: an interface; represents the Map that will hold MDC >context and has copy() method (replaces Hashtable) >- MDCContainerFactory: an interface; factory used by MDC to create new >containers (replaces new Hashtable()) > >I have provided a BasicMDCContainer and BasicMDCContainerFactory that >deliver the existing Hashtable implementation by default. > >ThreadLocalMap has been modified to expect an MDCContainer and uses its >copy() method to make the copy when a child thread is created. > >MDC has been modified to use the factory to create the container and >any references to Hashtable have been replaced with MDCContainer. The >factory is a static property and get/set has been added. To plug in a >new container, one just does MDC.setContainerFactory. > >LoggingEvent now uses MDCContainer.copy() in its getMDCCopy method. > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] -- Ceki Gülcü For log4j documentation consider "The complete log4j manual" ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]