Do SimpleLogger/StatusLogger use UTF8? I think (and hope) not, because the console usually only supports the platform default encoding. See also LOG4J2-255 for the gory details. :-)
On Tuesday, March 25, 2014, Matt Sicker <[email protected]> wrote: > Wait which stream stuff? The logger stream? Because that's totally > separate. I was talking about the underlying OutputStream used in > SimpleLogger/StatusLogger. I think this would be useful in regions where > UTF-8 is not widely used (e.g., Asia). > > > On 24 March 2014 22:16, Gary Gregory <[email protected]> wrote: > > Stepping back a bit... what real life problem is all of this stream stuff > solving? I hope we have good docs ;) > > Gary > > > -------- Original message -------- > From: Matt Sicker > Date:03/24/2014 22:02 (GMT-05:00) > To: Log4J Developers List > Subject: Re: Would like to change a bit of the SimpleLogger API. Feedback > requested. > > Good point. So in order to add configurable charset support, it would be > best to continue using streams instead of writers. The character set should > probably be stored in SimpleLoggerContext. I don't remember if specific > charset support is already there for core.Logger[Context], so that might be > worth looking into as well down the line. > > > On 24 March 2014 20:23, Bruce Brouwer <[email protected]> wrote: > > I think it should remain a PrintStream. The PrintWriter still uses a > charset by defaulting to the platform encoding, but you have no way to > choose it unless you specify that you are writing to a file. I think > PrintWriter needs some more constructor options when giving it an > OutputStream, but that's just my opinion. At least with PrintWriter you > have the option to choose the charset when giving it an OutputStream. > > What might make sense is to change the SimpleLoggerContext constructor to > pull out the charset name from the props when falling into the case where > it is creating a FileOutputStream. All you need to change is the line that > currently reads like this: > > ps = new PrintStream(os); > > change it to something like this: > > final String charset = > props.getStringProperty(SimpleLoggerContext.SYSTEM_PREFIX + "charset"); > if (charset != null) { > ps = new PrintStream(os, false, charset); > } else { > ps = new PrintStream(os); > } > > That will need another catch block, but that shouldn't be a big problem to > figure out. > > > > On Mon, Mar 24, 2014 at 12:20 AM, Matt Sicker <[email protected]> wrote: > > From what I can tell, it's when you use OutputStream instead of Writer > that you need to specify charsets. I think the writers have a more friendly > configuration mechanism just via Java properties or something. I'm not > fully sure, actually. > > > On 23 March 2014 23:09, Ralph Goers <[email protected]> wrote: > > For StatusLogger you would then have to add a charset attribute to the > configuration element wouldn't you? > > Ralph > > On Mar 23, 2014, at 7:09 PM, Matt Sicker <[email protected]> wrote: > > It's mainly for StatusLogger, but that idea did cross my mind. > > > On 23 March 2014 21:00, Ralph Goers <[email protected]> wrote: > > I'm sorry, I didn't ask the question correctly. SimpleLogger doesn't > currently accept a charset. Are you planning on adding a new properly to > SimpleLoggerContext to support this? I don't really have an objection but > am just wondering when other than the platform's default encoding would > want to be used. After all, SimpleLogger wasn't really > > -- > Matt Sicker > <[email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');>> > >
