Hi Nick, Thanks for your reply. Two queries: 1.I am able to do this but the string appears in a CDATA section as is, e.g. for a Korean string, the string appears as the following in the XML file:
<message><![CDATA[&#xC751;&#xC6A9;&#x20; ]] ></message> The sting passed to the code is: "응용 " I saw in the code and there it calculates certain weights and depending on the values it either writes the string as an escaped string or a CDATA section. My actual string is longer and thus because of a large number of "&"s, my weightStringEscapes exceeds weightCData (which is only 12 because there are no CDATA end section characters in the string). To avoid this, I forced my code to still write it as a escaped string and the result was the same except for the missing CDATA section's begin and end characters. I even tried writing decimal escapes i.e. writing &#<decimal value>; instead of &#x<hex value>; but the results are the same. What is the problem here? 2. We use two type of appenders one text and one XML, won't this solution create a problem with the text file where the message would appear as XML escaped string. What is the workaround to prevent this? Regards, Mayank ________________________________ From: Nick Durcholz [mailto:[email protected]] Sent: Tuesday, January 20, 2009 7:44 PM To: Log4NET User Subject: RE: Issues with Korean/Chinese locales in XmlLayout... To output Chinese or Korean characters using XmlLayout you could try escaping log messages before even sending them to the log4net ILog object. In C#, something like the following is what I'm talking about: public class Foo { private ILog log = LogManager.GetLogger(typeof(Foo)); private void LogSomething(string message) { //replace the chinese yen symbol with its xml character escape sequence //see http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references //for more info on escape sequences log.Debug(message.Replace("\u00A5", "¥")); } } That is a workaround that might work for you, but it sounds like an issue with XmlLayout class IMO. XmlLayout is responsible for converting log messages to xml, so it should correctly escape unicode characters for you and not require the caller to have knowledge of the log output format. For the build issue, it sounds like you are running into a strong naming issue. The private key used to sign log4net.dll is not distributed with the source download packages. If you compile an application against log4net.dll that is distributed by Apache and later replace that with a modified log4net.dll that you compiled, then you will get this error (because the strong name keys are not the same). I would suggest that if you are going to modify the log4net source and compile it yourself that you create a new strong name key and use that to sign your modified version. You will then need to recompile everything that references log4net in your application (make sure it references the customized dll at compile time). ________________________________ From: Garg, Mayank [mailto:[email protected]] Sent: Tuesday, January 20, 2009 12:02 PM To: [email protected] Subject: Issues with Korean/Chinese locales in XmlLayout... Hi, I am using v1.2.10 and having issues with Korean and Chinese locales. I am using XmlLayout and in the XML log file, messages (contents of the element "message") in Korean and Chinese languages appear as "????". I am using the correct encoding "utf-8", however I tried with other possible encodings supporting Unicode but the problem did not get solved. I debugged the code and found that in Transform class, MaskXmlInvalidCharacters function escapes the valid Korean and Chinese characters as "?" characters because it thinks they are invalid XML unicode characters, its basically the following array defined in Transform class which is creating the problem: private static Regex INVALIDCHARS=new Regex(@"[^\x09\x0A\x0D\x20-\xFF\u00FF-\u07FF\uE000-\uFFFD]",RegexOptions.Compiled); Could anybody suggest a possible workaround for this? If I bypass the masking step, the message appears correctly in the log file. Or, is this a bug which should be solved in a certain manner? One more issue that I am facing is that we had included the log4net dll long time back in our sources as a reference. Now, if I try to rebuild the dll from the log4net sources and try replacing it with the older dll, our sources doesn't get built and the following compiler error is thrown: Error 796 Unknown build error, 'The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)' I have tried the following things: 1.Building log4net sources with VS2005 and keeping the conditional compilation sysmbols as NET;NET_2_0 as well as NET;NET_1_0 2.Building log4net sources with VS2008 and keeping the target framework as 3.5 But nothing seems to work. The old log4net dll seems to have been built on VS2005 with conditional compilation sysmbols as NET;NET_2_0 and our sources are built using VS 2008 using target framework as 3.5. What is it that I might be doing wrong? Initially I was getting errors related to strong names but I resolved it by generating the .snk file as mentioned on the Apache website and signing the dll. Please help. Regards, Mayank
