Hello Nathan,
I guess this is what is happening:
* one thread is writing a loggingEvent to the log file,
=> the PatternParser calls toString() on all MDC values and hence iterates
over the elements in your TreeMap
* at the same time another thread updates the TreeMap
causing a java.util.ConcurrentModificationException in the first thread.
To avoid this type of problems, I would advise to only put String objects in
the MDC.
MDC.put("map", myTreeMap.toString());
instead of
MDC.put("map", myTreeMap);
Maarten
On Feb 11, 2008 12:38 AM, Nathan Clement <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I've examined this exception further, and it seems to be caused by the
> fact that I'm using a non-synchronized TreeMap in the MDC. I don't
> understand why this would cause an issue seeing as the MDC uses a
> ThreadLocalMap, so synchronization should be unnecessary. However, I've
> replaced the TreeMap with a synchronized map and will hope that the error
> doesn't occur any more.
>
> Regards,
>
> Nathan
>
> ----- Original Message ----
> From: Nathan Clement <[EMAIL PROTECTED]>
> To: [email protected]
> Sent: Friday, 8 February, 2008 2:17:57 PM
> Subject: Uncaught Exception in Log4J 1.2.15
>
> Hi,
>
> I got this uncaught exception in our production system and am sending it
> to this list as per the FAQ. Do you need any more information to locate the
> problem?
>
> Thanks,
>
> Nathan
>
> java.util.ConcurrentModificationException
> at java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1031)
> at java.util.TreeMap$EntryIterator.next(TreeMap.java:1052)
> at java.util.TreeMap$EntryIterator.next(TreeMap.java:1050)
> at java.util.AbstractMap.toString(AbstractMap.java:587)
> at org.apache.log4j.helpers.PatternParser$MDCPatternConverter.convert(
> PatternParser.java:467)
> at org.apache.log4j.helpers.PatternConverter.format(PatternConverter.java
> :65)
> at org.apache.log4j.PatternLayout.format(PatternLayout.java:502)
> at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:302)
> at com.metiom.system.DailyFileAppender.subAppend(DailyFileAppender.java
> :321)
> at org.apache.log4j.WriterAppender.append(WriterAppender.java:160)
> at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
> at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(
> AppenderAttachableImpl.java:66)
> at org.apache.log4j.Category.callAppenders(Category.java:206)
> at org.apache.log4j.Category.forcedLog(Category.java:391)
> at org.apache.log4j.Category.debug(Category.java:260)
>
>
> Get the name you always wanted with the new y7mail email address.
> www.yahoo7.com.au/y7mail
>
>
> Get the name you always wanted with the new y7mail email address.
> www.yahoo7.com.au/y7mail
>
>