To resolve the problem I replaced the list of if..else in L4PatternLayout statements with the following code:

// Minimum length
if (minLength > 0 && [tempString length] < minLength)
{
int length = minLength - [tempString length];
NSMutableString *spaces = [NSMutableString stringWithCapacity:length];
for (int i=0; i < length; i++)
{
[spaces appendString:@" "];
}
if (leftJustify)
{
tempString = [tempString stringByAppendingString:spaces];
} else {
tempString = [spaces stringByAppendingString:tempString];
}
}
// Maximum length
if (maxLength > 0 && [tempString length] > maxLength)
{
tempString = [tempString substringFromIndex:[tempString length] - maxLength];
}
[finalResultString appendString:tempString];