DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17377>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17377 PatternConverter.format() does not truncate strings correctly Summary: PatternConverter.format() does not truncate strings correctly Product: Log4j Version: 1.2 Platform: All OS/Version: All Status: NEW Severity: Normal Priority: Other Component: Layout AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Hi there, as I discovered by extending log4j patternlayout for integrating more information from an extended loggingevent, the format() method doesn't handle the case of making long strings shorter correctly, e.g. if I have following log messages: a) log.debug("a debug info"); b) log.info("an info"); and use the following pattern "%3.3p" I would expect the following output: a) BUG b) NFO This is delivered by the format() method, but less useful - I wanted to get the first three chars of the priority - so I would suggest to use "%-3.3p" (left align is ON), but I get the same output as above. The fix is as easy. Change the PatternConverter.format() method as follows: < if(len > max) < sbuf.append(s.substring(len-max)); < else if(len < min) { -- > if(len > max) > if (leftAlign) { > sbuf.append(s.substring(0,max)); > } else { > sbuf.append(s.substring(len-max)); > } > else if(len < min) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]