Here is the code Chainsaw uses to convert patternlayouts into something useful, using only log4j APIs. In the case of the latest developer snapshot of Chainsaw, it is used to build a Chainsaw config directly from log4j xml or properties file fileappender entries.
Use the converters and fields populated by PatternParser#parse to do what you want. The PatternParser class is included in the log4j 'extras' companion.
From http://svn.apache.org/repos/asf/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogFilePatternLayoutBuilder.java
public static String getLogFormatFromPatternLayout(String patternLayout) {
String input = OptionConverter.convertSpecialChars(patternLayout);
List converters = new ArrayList();
List fields = new ArrayList();
Map converterRegistry = null;
PatternParser.parse(input, converters, fields, converterRegistry, PatternParser.getPatternLayoutRules());
return getFormatFromConverters(converters);
}
If you actually want something that will read a log file conforming to a specific PatternLayout and generate log4j LoggingEvents, see LogFilePatternReceiver. Chainsaw uses the getLogFormatFromPatternLayout method to convert the patternLayout into the LogFormat required by the receiver.
By the way, the developer snapshot of Chainsaw contains a lot of additional new features - if you want to try it out, you can get it here:
http://people.apache.org/~sdeboy