[ 
https://issues.apache.org/jira/browse/LOG4J2-812?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14614321#comment-14614321
 ] 

Gary Gregory edited comment on LOG4J2-812 at 7/5/15 5:25 PM:
-------------------------------------------------------------

{quote}I am not crazy about this solution simply because I am not crazy about 
having a ThreadLocal per DatePatternConverter.{quote}

Why? How many DatePatternConverter's can there be in an application? I guess 
some apps could create hundreds of file appenders for different data based on 
markers. But if you do that, you're going to have a lot of overhead anyway.

If an app has a lot of thread coming and going, that means a lot of thread 
locals coming and going as well. Is that the issue you are worried about?

Does Java 8's new date-time code offer lock free formatting?


was (Author: garydgregory):
{quote}I am not crazy about this solution simply because I am not crazy about 
having a ThreadLocal per DatePatternConverter.{quote}

Why? How many DatePatternConverter's can there be in an application? I guess 
some apps could create hundreds of file appenders for different data based on 
markers. But if you do that, you're going to have a lot of overhead anyway.

Does Java 8's new date-time code offer lock free formatting?

> Performance optimization: avoid use of synchronized SimpleDateFormat in 
> Dat​ePatternCo​nverter 
> -----------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-812
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-812
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Pattern Converters, Performance Benchmarks
>    Affects Versions: 2.0.2
>            Reporter: Mohit Anchlia
>            Assignee: Remko Popma
>             Fix For: 2.3
>
>         Attachments: LOG4J2-812-patch.txt
>
>
> Threads seem to be blocking on class 
> org.apache​.loggin.lo​g4j.core.p​attern.Dat​ePatternCo​nverter. It's short 
> lived but is visible in profiler. It also is adding on to CPU. Here is the 
> mail conversation on the mailing list:
> {quote}
> Ralph Goers [email protected] via logging.apache.org  
> The converter uses a SimpleDateFormat which is not thread safe and so is 
> synchronized. I am sure there might be minor optimizations that could be done 
> to this
>  What I would do is modify DatePatternConverter to
>  a) use Java 8’s java.time.format.DateTimeFormatter if running on Java 8
>  b) use Joda Time’s DateTimeFormat if it is present.
>  c) create a pool of SimpleDateFormat objects and use those.
>  Please create a Jira issue for this.
>  Ralph
> {quote}
> ----
> One alternative that  was suggested on the mailing list is to use commons 
> lang FastDateFormat to format log timestamps.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to