You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Mohammed Mansoor <ma...@gmail.com> on 2009/01/26 11:12:28 UTC

Backup log shows question marks (??) for Chinese language

Our application takes a backup of files selected from the folders specified
by the user. 
The backup log is written using the Log4j (log4j-1.2.11.jar).
When the backup is taken in Chinese language, the backup log is written and
it shows question marks(??) in place of the backup details. We tried using
the appender UTF-8 in the log4j properties as shown below,

log4j.appender.BackupFile.Encoding=UTF-8

We also tried using ISO-8859-1 and Shift_JIS in place of UTF-8. But that
didn't help. We still get garbled characters for the text written in the
backup log. Can you please suggest on this. Thanks!!

-- 
View this message in context: http://www.nabble.com/Backup-log-shows-question-marks-%28--%29-for-Chinese-language-tp21663054p21663054.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


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


log4j help: disabling org.apache.commons.digester.Digester logs

Posted by Ravi <ra...@cox.net>.
Hi: I am trying to use log4j for the first time to perform logging. I am 
having one trouble. I want the java application to print some stuff 
within my code. But it also prints a lot of stuff related to 
org.apache.commons.digester.Digester in addition to my log statements 
[DEBUG [main] checkRequest (checkRequest.java)]. The application name is 
checkRequest. Is there anyway to dsiable the 
org.apache.commons.digester.Digester logs?

Here's what I have in the log4j.xml
========================
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

<appender name="Console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d %-5p [%t] %C (%F:%L) - %m%n"/>
</layout>
</appender>
<logger name="com.bmc.arsys">
<level value="fatal" />
</logger>

<!--Set root category priority to fatal -->
<root>
<priority value ="debug" />
<appender-ref ref="Console" />
</root>

</log4j:configuration>
=====================

Here's my code:
When I run this code as soon as the code reaches the "server = new 
ARServerUser" line, I get a lot of logs which I want disable.
===========================
import java.sql.*;
import java.io.*;
import java.util.*;
import java.lang.*;
import com.bmc.arsys.api.*;
import javax.mail.*;
import org.apache.log4j.Logger;
import org.apache.log4j.Level;

public class checkRequest {
private static Logger logger = Logger.getLogger(checkRequest.class);

public static void main(String args[]){
String REMENV = args[0];
logger.debug("Here is some DEBUG");
if(args.length > 1) {
String requestID = args[1];
}

ARServerUser server = null;

if(REMENV.equals("TEST")) {
logger.debug("Connecting to Test remedy");
server = new ARServerUser("Demo", "r3m3dy", "", "rearsyst01");
}
server.logout();

}
}
=========================

2009-01-25 21:27:51,230 DEBUG [main] checkRequest (checkRequest.java:16) 
- Here is some DEBUG
2009-01-25 21:27:51,238 DEBUG [main] checkRequest (checkRequest.java:24) 
- Connecting to Test remedy
2009-01-25 21:27:51,429 DEBUG [main] 
org.apache.commons.configuration.ConfigurationUtils 
(ConfigurationUtils.java:515) - Configuration loade
d from the context classpath (arsys_base.xml)
2009-01-25 21:27:51,537 DEBUG [main] 
org.apache.commons.digester.Digester (Digester.java:1249) - 
setDocumentLocator(com.sun.org.apache.xerce
s.internal.parsers.AbstractSAXParser$LocatorProxy@ccc588)
2009-01-25 21:27:51,540 DEBUG [main] 
org.apache.commons.digester.Digester (Digester.java:1283) - startDocument()
2009-01-25 21:27:51,543 DEBUG [main] 
org.apache.commons.digester.Digester (Digester.java:1318) - 
startElement(,,configuration)
2009-01-25 21:27:51,546 DEBUG [main] 
org.apache.commons.digester.Digester (Digester.java:1325) - Pushing body 
text ''
2009-01-25 21:27:51,549 DEBUG [main] 
org.apache.commons.digester.Digester (Digester.java:1344) - New 
match='configuration'
2009-01-25 21:27:51,552 DEBUG [main] 
org.apache.commons.digester.Digester (Digester.java:1372) - No rules 
found matching 'configuration'.
2009-01-25 21:27:51,555 DEBUG [main] 
org.apache.commons.digester.Digester (Digester.java:1002) - characters(
)
2009-01-25 21:27:51,558 DEBUG [main] 
org.apache.commons.digester.Digester (Digester.java:1002) - characters(
)
2009-01-25 21:27:51,560 DEBUG [main] 
org.apache.commons.digester.Digester (Digester.java:1318) - 
startElement(,,xml)
2009-01-25 21:27:51,562 DEBUG [main] 
org.apache.commons.digester.Digester (Digester.java:1325) - Pushing body 
text '

'
2009-01-25 21:27:51,564 DEBUG [main] 
org.apache.commons.digester.Digester (Digester.java:1344) - New 
match='configuration/xml'
2009-01-25 21:27:51,567 DEBUG [main] 
org.apache.commons.digester.Digester (Digester.java:1359) - Fire begin() 
for FactoryCreateRule[classN
ame=null, attributeName=null, 
creationFactory=org.apache.commons.configuration.ConfigurationFactory$FileConfigurationFactory@73a34b]
2009-01-25 21:27:51,579 INFO [main] 
org.apache.commons.configuration.ConfigurationFactory$FileConfigurationFactory 
(ConfigurationFacto

TIA
Ravi



-- 
Thank you,
RaVi


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


Re: Backup log shows question marks (??) for Chinese language

Posted by Curt Arnold <ca...@apache.org>.
On Jan 26, 2009, at 4:12 AM, Mohammed Mansoor wrote:

>
> Our application takes a backup of files selected from the folders  
> specified
> by the user.
> The backup log is written using the Log4j (log4j-1.2.11.jar).
> When the backup is taken in Chinese language, the backup log is  
> written and
> it shows question marks(??) in place of the backup details. We tried  
> using
> the appender UTF-8 in the log4j properties as shown below,
>
> log4j.appender.BackupFile.Encoding=UTF-8
>
> We also tried using ISO-8859-1 and Shift_JIS in place of UTF-8. But  
> that
> didn't help. We still get garbled characters for the text written in  
> the
> backup log. Can you please suggest on this. Thanks!!
>

Please don't post to both log4j-dev and log4j-user.

There are not enough details in your report to troubleshoot.

ISO-8859-1 is the Latin 1 character set and can only represent Unicode  
code points from 0 to 255.  Any attempt to write an Chinese character  
would be expected to produce a ? since the attempt to convert the  
character to the encoding will fail and log4j substitutes a "?" when  
charset encoding fails.

Since the "J" in Shift_JIS stands for Japanese, it seems reasonable to  
think that an attempt to encode a Chinese character would also fail.

UTF-8 is capable of representing any Unicode code point, so you should  
not expect a charset encoding failure.  However, it is possible that  
whatever you are using to display the file is assuming a different  
character set, so valid UTF-8 sequence is incorrectly interpreted,  
however typically this would be displayed as 2-3 symbols or accented  
characters.

Since it appears that you are able to reproduce the problem.  I would  
suggest:

1) Try log4j 1.2.15.  If there is a log4j issue, it may have already  
be fixed.

2) Try UTF-16 encoding.  That will eliminate the ambiguity on the  
encoding.

3) Try UTF-8 encoding again, but examine the output with a hex editor  
(for example: ghex or 0xED) to check what bytes are being written to  
the file.

4)  Try build the SVN HEAD on your platform.  The unit tests contain  
several tests of encoding and decoding.  If those fail on your  
platform, then it may be an issue with your JVM.

If you are still seeing a problem, it would be good to get a full  
report including a test app, configuration file, the problematic  
output and details of your configuration (OS version and vendor, JVM  
version and vendor, etc).


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