Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.0.2
-
None
Description
Threads seem to be blocking on class org.apache.loggin.log4j.core.pattern.DatePatternConverter. 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:
Ralph Goers ralph.goers@dslextreme.com 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
One alternative that was suggested on the mailing list is to use commons lang FastDateFormat to format log timestamps.
Attachments
Attachments
Issue Links
- is depended upon by
-
LOG4J2-1097 [Perf] Custom TimeFormat
-
- Resolved
-
-
LOG4J2-930 Improve PatternLayout performance
-
- Closed
-
- is duplicated by
-
LOG4J2-852 [Perf] Use FastDateFormat to format %d timestamps
-
- Closed
-
- is related to
-
LOG4J2-1102 Follow up: remaining tasks related to introducing FastDateFormat
-
- Open
-