Bug 46592 - trim() on property file entries
Summary: trim() on property file entries
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Appender (show other bugs)
Version: 1.2
Hardware: PC Windows 2000
: P5 trivial
Target Milestone: ---
Assignee: log4j-dev
Depends on:
Reported: 2009-01-23 05:28 UTC by Peter Jelitsch
Modified: 2010-05-07 07:17 UTC (History)
0 users

Patch adds trim() to encoding setter (420 bytes, patch)
2009-12-03 14:36 UTC, Sven Diedrichsen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Jelitsch 2009-01-23 05:28:34 UTC
I just spent some time finding out, why i could not tell log4j to write log files in UTF-8. I got the error "Error initializing output writer." and "Unsupported encoding?" When debugging into it, i discovered, that it was a UTS fault, as the line in the property file said "log4j.appender.ESP.Encoding=UTF-8 " (note the space at the end). Therefore I'd like to suggest to introduce some string trimming in the method WriterAppend.createWriter(OutputStream). String enc=getEncoding().trim(); or so.
Comment 1 Sven Diedrichsen 2009-12-03 14:36:40 UTC
Created attachment 24667 [details]
Patch adds trim() to encoding setter

This patch adds trimming of the encoding string to the setter method.
Comment 2 Sven Diedrichsen 2009-12-03 14:38:14 UTC
I have added trimming to the setter of the encoding property.
Comment 3 Sven Diedrichsen 2009-12-03 15:06:56 UTC
The trimming should already be done. Please see PropertySetter class:

- snip
  Object convertArg(String val, Class type) {
    if(val == null)
      return null;

    String v = val.trim();
    if (String.class.isAssignableFrom(type)) {
      return val;
- snip

Why does this not work for you?
Comment 4 Matthew Buckett 2010-05-07 07:17:15 UTC
I've just encountered this bug with log4j 1.2.15.