[jboss-jira] [JBoss JIRA] (LOGMGR-104) SyslogHandler doesn't handle multi-byte characters correctly
Kyle Shanahan (JIRA)
issues at jboss.org
Sun Mar 9 18:32:33 EDT 2014
[ https://issues.jboss.org/browse/LOGMGR-104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12951368#comment-12951368 ]
Kyle Shanahan edited comment on LOGMGR-104 at 3/9/14 6:32 PM:
--------------------------------------------------------------
Sorry, my examples doesn't have enough patterns. Well, let's see some examples:
- Logging code
!corrupted2.png!
- Output
!corrupted.png!
You can see that 2byte UTF8 characters are not corrupted, and 3byte (no surrogate pairs) and 4byte (with surrogate pairs) characters are corrupted.
Also, 2byte characters are not corrupted because I'm using UTF-8, but current implementation is UTF-8 dependent, so I guess it's might better to change to encoding independent implementation. my pull request has this fix too.
I updated my example project at GitHub.
was (Author: xkylex):
Sorry, my examples doesn't have enough patterns. Well, let's see some examples:
- Logging code
!corrupted2.png!
- Output
!corrupted.png!
You can see that 2byte UTF8 characters are not corrupted, and 3byte (no surrogate pairs) and 4byte (with surrogate pairs) characters are corrupted.
Also, 2byte characters are not corrupted because I'm using UTF-8, but current implementation is UTF-8 dependent, so I guess it's might better to change to encoding independent implementation. my pull request has this fix too.
I would update my example project later.
> SyslogHandler doesn't handle multi-byte characters correctly
> ------------------------------------------------------------
>
> Key: LOGMGR-104
> URL: https://issues.jboss.org/browse/LOGMGR-104
> Project: JBoss Log Manager
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: core
> Affects Versions: 1.5.2.Final
> Environment: - WildFly 8.0.0.Final
> - Oracle JDK7u51
> - OS X 10.9.2
> Reporter: Kyle Shanahan
> Assignee: David Lloyd
> Attachments: corrupted.png, corrupted2.png, corrupted3.png
>
>
> SyslogHandler doesn't handle multi-byte characters correctly.
> I tried to log multi-byte message with both of org.jboss.logmanager.handlers.SyslogHandler and org.apache.log4j.net.SyslogAppender for same message, only SyslogHandler output were corrupted.
> Step to reproduce (It might need to define -Dfile.encoding=UTF-8 in _JAVA_OPTIONS):
> 1. define a facility local1 at localhost and make syslog accept UDP packets.
> 2. define a logger:
> {noformat}
> /subsystem=logging/logger=utf8mb4log:add(level=INFO)
> {noformat}
> 3. define a SyslogHandler:
> {noformat}
> /subsystem=logging/custom-handler=TEST_SH:add(class="org.jboss.logmanager.handlers.SyslogHandler", module="org.jboss.logmanager", formatter="SyslogHandler: %s%e", level=INFO, properties={serverHostname="localhost:514", facility="LOCAL_USE_1", truncate=false, maxLength=1024, syslogType="RFC3164" })
> /subsystem=logging/logger=utf8mb4log:assign-handler(name=TEST_SH)
> {noformat}
> 4. define a SyslogAppender:
> {noformat}
> /subsystem=logging/custom-handler=TEST_LOG4J:add(class="org.apache.log4j.net.SyslogAppender", module="org.apache.log4j", formatter="log4j: %s%e", level=INFO, properties={syslogHost="localhost:514", facility="local1"})
> /subsystem=logging/logger=utf8mb4log:assign-handler(name=TEST_LOG4J)
> {noformat}
> 5. get and deploy example project at https://github.com/lbtc-xxx/utf8mb4log
> 6. Access the servlet http://localhost:8080/utf8mb4log/
> And you will get like this: (I can't put 4 byte UTF-8 characters here... because database error occured):
> {noformat}
> Mar 8 17:29:09 UNKNOWN_HOSTNAME java[9896]: SyslogHandler: ????????????
> {noformat}
> I would send a pull request later.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list