Bug 50039 - Request: single character form of priority in PatternLayout
Summary: Request: single character form of priority in PatternLayout
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Layout (show other bugs)
Version: 1.2
Hardware: PC Linux
: P2 enhancement
Target Milestone: ---
Assignee: log4j-dev
Depends on:
Reported: 2010-10-01 15:59 UTC by Andrew Pimlott
Modified: 2010-10-28 23:39 UTC (History)
0 users

left-truncation patch (using syntax %+.2p for example) (6.09 KB, application/octet-stream)
2010-10-02 01:42 UTC, Scott Deboy
left-truncation patch (using syntax %+.2p for example) - updated (missed break in case block) (6.10 KB, application/octet-stream)
2010-10-02 18:59 UTC, Scott Deboy

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pimlott 2010-10-01 15:59:21 UTC
Priorities are uniquely identified by their first character and this would keep logs more compact.  However, this doesn't seem to be possible in PatternLayout or EnhancedPatternLayout.  Suggest either a new conversion type, or a way to truncate from the end.
Comment 1 Scott Deboy 2010-10-02 01:42:29 UTC
Created attachment 26111 [details]
left-truncation patch (using syntax %+.2p for example)
Comment 2 Scott Deboy 2010-10-02 18:59:04 UTC
Created attachment 26112 [details]
left-truncation patch (using syntax %+.2p for example) - updated (missed break in case block)
Comment 3 Scott Deboy 2010-10-02 18:59:26 UTC
Updated patch to add missing break
Comment 4 Curt Arnold 2010-10-03 12:09:20 UTC
We voted to move EnhancedPatternLayout into log4j main, but it still needs to be in extras for users who combine extras with earlier log4j's.

Looking at the patch, it looks like you changed a public constructor's signature for FormattingInfo.  Since I think that is a released public class, you can't change the signature, but you could add an additional constructor.  Needing to change existing tests strongly suggests a breaking change.
Comment 5 Scott Deboy 2010-10-03 12:56:14 UTC
I'm fine with maintaining compatibility, but honestly, FormattingInfo seems useless to end users (it happens to be public but doesn't have to be, and it is final).

If there ever is a log4j 2.0, I would suggest we make explicit statements of support for compatibility moving forward - specifically, I think we need to define interfaces for anything we expect end users to want to extend and we maintain those interface contracts, and everything else is implementation and users should have no expectation of implementation classes going forward, even if they are public.

log4j has been mired in its current state in large part (IMO) because of resistance to modify the api due to concerns over backward compatibility.  Its definitely a dis-incentive to participation if everything that is a public class can only have additions made and never have things removed or changed.
Comment 6 Ceki Gulcu 2010-10-05 07:37:14 UTC
Scott's last comment (dated 2010-10-03 12:56:14 EDT) makes a very good and rather constructive point.
Comment 7 Curt Arnold 2010-10-28 02:03:47 UTC
Looked at it again, but can't integrate tonight.  The patch at least needs some documentation in ExtendedPatternLayout and test case using the feature in pattern layout.

Using the "+" sign for right truncation (the patch does right truncation despite the name) is unsatisfying since "-" is used for left alignment (right alignment is the default) and you can have a field that is left aligned and right truncated and "%+-4C" doesn't look satisfying to me.    I haven't found any examples of right or left truncation flags.  I thought about "*", but I'm inclined to "!" at the moment.
Comment 8 Curt Arnold 2010-10-28 23:39:03 UTC
Committed a patch using "!" as the right truncation modifier in rev 1028600.