logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LOG4J2-1636) Console Appender does not pick up Oracle Java 8's sun.stdout.encoding and sun.stderr.encoding
Date Mon, 10 Oct 2016 18:27:20 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-1636?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15563069#comment-15563069
] 

Gary Gregory edited comment on LOG4J2-1636 at 10/10/16 6:27 PM:
----------------------------------------------------------------

Please check https://repository.apache.org/content/repositories/snapshots/ or Git master for
a fix.

If you do not specify a {{Layout}} in your {{Console}} Appender, then you will get a default
layout built by the Console Appender which will use the {{sun.stdout.encoding}} value if it
is present. If {{sun.stdout.encoding}} is absent, then the appender uses {{Charset.defaultCharset()}}.

This is what is still troublesome:
- {{PatternLayout}} uses {{Charset.defaultCharset()}} for the default, which makes sense in
the big picture.
- If you specify a {{Layout}} without a {{charset}} field, then the {{Charset.defaultCharset()}}
kicks in.
- When a configuration is built, a {{PatternLayout}} does not know it is being built in a
{{Console}} Appender. The {{Layout}} gets built first, then the Appender.
- What if you really want to use {{Charset.defaultCharset()}} in your configuration no matter
what {{sun.stdout.encoding}} says?

I'm not sure how to solve this cleanly. 

Suggestions welcome.






was (Author: garydgregory):
Please check Uploading: https://repository.apache.org/content/repositories/snapshots/ or Git
master for a fix.

If you do not specify a {{Layout}} in your {{Console}} Appender, then you will get a default
layout built by the Console Appender which will use the {{sun.stdout.encoding}} value if it
is present. If {{sun.stdout.encoding}} is absent, then the appender uses {{Charset.defaultCharset()}}.

This is what is still troublesome:
- {{PatternLayout}} uses {{Charset.defaultCharset()}} for the default, which makes sense in
the big picture.
- If you specify a {{Layout}} without a {{charset}} field, then the {{Charset.defaultCharset()}}
kicks in.
- When a configuration is built, a {{PatternLayout}} does not know it is being built in a
{{Console}} Appender. The {{Layout}} gets built first, then the Appender.
- What if you really want to use {{Charset.defaultCharset()}} in your configuration no matter
what {{sun.stdout.encoding}} says?

I'm not sure how to solve this cleanly. 

Suggestions welcome.





> Console Appender does not pick up Oracle Java 8's sun.stdout.encoding and sun.stderr.encoding

> ----------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1636
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1636
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders, Layouts
>         Environment: Windows
>            Reporter: Eldar Gabdullin
>            Assignee: Gary Gregory
>
> The Oracle Java 8 platform supports two system properties to configure the System console:
sun.stdout.encoding and sun.stderr.encoding.
> ----
> Default log4j configuration prints to console using platform's default encoding, however
that's not what standard windows console expects.
> I.e.
> {code}
> System.out.println("Поехали"); // works just fine
> System.out.write("Поехали!\n".getBytes(Charset.defaultCharset())); // characters
are messed up
> log.info("Поехали"); // messed up in the same way
> {code}
> This happens not just on one machine, but on all Windows desktops and servers in our
organization.
> Can we have out of the box Layout/Appender which prints directly to System.out/err?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message