Bug 45941 - Custom PatternLayout
Summary: Custom PatternLayout
Status: RESOLVED FIXED
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Layout (show other bugs)
Version: unspecified
Hardware: PC All
: P2 enhancement
Target Milestone: ---
Assignee: log4j-dev
URL: http://logging.apache.org/log4j/1.2/a...
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-03 02:58 UTC by A.Bergues
Modified: 2009-01-08 09:11 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description A.Bergues 2008-10-03 02:58:04 UTC
For the moment, you can only use predefined patternLayout here

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html

An evolution could be to add a system to define our own layout

basically a custom layout could be

---------------------------------------------------------
public class MyPidLayout implements CustomConversionLayout{

     char getConversionCharacter(){
            return 'y';
      }

     String getConversionValue(){
           return properties.getProperty("Pid"));
      }

}
----------------------------------------------------------

André Bergues
Comment 1 Curt Arnold 2008-10-03 06:15:52 UTC
Please look at EnhancedPatternLayout in the extras companion.  That is a back port of the PatternLayout from the abandoned log4j 1.3 development and supports user supplied conversion patterns and see if it does what you are wanting to do.  If not, please describe what you want to do more concretely.
Comment 2 Curt Arnold 2009-01-08 09:11:53 UTC
Marking as fixed as I believe EnhancedPatternLayout addresses this issue.