Write hebrew with log4net
Asked Answered
B

3

6

I write mixed Hebrew and English characters to a file using log4net but instead of Hebrew i see question marks.

I've tried setting Application's and Thread's culture info to 'he-IL' but it doesn't seem to help.

Does log4net support Hebrew characters? If so, how can i make it work? Thanks

Edit: This is my config section:

<appender name="ErrorsFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
  <param name="File" value="c:\\taskman\\service.log"/>
  <param name="AppendToFile" value="true" />
  <rollingStyle value="Date"/>
  <datePattern value="'service.'yyyy-MM-dd'.log'"/>
  <layout type="log4net.Layout.PatternLayout,log4net">
    <param name="ConversionPattern" value="%d;%m%n"/>
  </layout>
</appender>  

The hebrew text comes from the DB which is an SQL server 2005.

Bathometer answered 8/7, 2013 at 11:5 Comment(5)
What are you viewing the output in? Could it be you're viewing the result with a font that doesn't support your character set?Pickaback
I've tried Notepad, EditPlus and VS2010, all show the same.Bathometer
Can you add your log4net configuration section. Where are you taking the values form? DB? Web page?Mcmillian
I'm having the same problem. Have you manage to display Hebrew yet?Scrivings
Mr Mush, r u Eyal Mush?Bathometer
S
4

Add the following line to your app.config file, in the appender section:

<encoding value="windows-1255" />
Scrivings answered 8/11, 2013 at 6:59 Comment(0)
R
2

After I tried adding the windows-1255 to the encoding value I still had issue with Hebrew text.

I ended up adding : <encoding value="utf-8" />

And it worked only in UTF-8 mode

Reagent answered 29/1, 2018 at 7:52 Comment(0)
C
1

Encountered the same issue here. I have configured log4net with the following settings:

<log4net>
    <root>
      <level value="DEBUG" />
      <appender-ref ref="LogFileAppender" />
    </root>
    <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >
      <param name="File" value="giscraweler.txt" />
      <encoding value="windows-1255" />
      <param name="AppendToFile" value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="10MB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%date [%thread] %-5level - %message%newline" />
      </layout>
    </appender>
</log4net>

I saw the font good in the Visual studio debug window, But when i opened the log file with Notepad++ - The text was not right, i saw weird characters.

How to fix ? Set up your "character sets" as first comment suggested.
I selected character sets windows-1255 and now i see the hebrew fonts.

Cacao answered 6/9, 2017 at 19:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.