0

This is my appender for jsonl logging from logback.xml file

<?xml version="1.0" encoding="utf-8"?>
    <appender name="JSONL_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
       <file>logs/card_gate_json.jsonl</file>
       <encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
       <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
          <FileNamePattern>logs/card_gate.%d{yyyy-MM-dd}.%i.log.zip</FileNamePattern>
          <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
             <maxFileSize>50MB</maxFileSize>
          </timeBasedFileNamingAndTriggeringPolicy>
          <MinIndex>1</MinIndex>
          <MaxIndex>50</MaxIndex>
       </rollingPolicy>
    </appender>
    

This is example log, note, that cyrillic text is in ascii code.

{"@timestamp":"2016-09-22T14:04:40.886+03:00","@version":1,"message":"CARD Gate \u0432\u0435\u0440\u0441\u0438\u044F 003.00","logger_name":"ru.billing.cardgate.Cardgate","thread_name":"main","level":"INFO","level_value":20000,"HOSTNAME":"WKS-18384"}
{"@timestamp":"2016-09-22T14:04:40.902+03:00","@version":1,"message":"\u0418\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0430\u0446\u0438\u044F \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u0439 \u0441 \u0431\u0430\u043D\u043A\u0430\u043C\u0438","logger_name":"ru.billing.cardgate.Cardgate","thread_name":"main","level":"INFO","level_value":20000,"HOSTNAME":"WKS-18384"}
{"@timestamp":"2016-09-22T14:04:40.927+03:00","@version":1,"message":"\u041F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 \u0441\u0432\u044F\u0437\u0438 \u0441 \u0431\u0430\u043D\u043A\u0430\u043C\u0438. \u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 acquire_emulator_mode = true","logger_name":"ru.billing.cardgate.bankclient.BankFactory","thread_name":"main","level":"WARN","level_value":30000,"HOSTNAME":"WKS-18384"}
{"@timestamp":"2016-09-22T14:04:40.928+03:00","@version":1,"message":"\u0421\u0442\u0430\u0440\u0442 HTTPS \u0441\u0435\u0440\u0432\u0435\u0440\u0430","logger_name":"ru.billing.cardgate.Cardgate","thread_name":"main","level":"INFO","level_value":20000,"HOSTNAME":"WKS-18384"}
{"@timestamp":"2016-09-22T14:04:40.933+03:00","@version":1,"message":"Last transaction number before initialisation is 123 date Thu Sep 22 00:00:00 MSK 2016","logger_name":"ru.billing.cardgate.context.TransactionCounter","thread_name":"main","level":"INFO","level_value":20000,"HOSTNAME":"WKS-18384"}
{"@timestamp":"2016-09-22T14:04:40.934+03:00","@version":1,"message":"Calendar day of year value 266","logger_name":"ru.billing.cardgate.context.TransactionCounter","thread_name":"main","level":"INFO","level_value":20000,"HOSTNAME":"WKS-18384"}
{"@timestamp":"2016-09-22T14:04:40.938+03:00","@version":1,"message":"SAXBuilder pool initialized with 2 SAXBuilder","logger_name":"ru.billing.cardgate.context.saxPool.SaxPool","thread_name":"main","level":"DEBUG","level_value":10000,"HOSTNAME":"WKS-18384"}
{"@timestamp":"2016-09-22T14:04:40.938+03:00","@version":1,"message":"Current directory: C:\\Users\\Sultan.Isaev\\Desktop\\SFolder\\Code\\unipay_iso8583_gate\\User_Part\\UNIPAY_ISO8583_GATE","logger_name":"ru.billing.cardgate.server.CardServer","thread_name":"main","level":"INFO","level_value":20000,"HOSTNAME":"WKS-18384"}
{"@timestamp":"2016-09-22T14:04:40.938+03:00","@version":1,"message":"\u0425\u0440\u0430\u043D\u0438\u043B\u0438\u0449\u0435 \u043A\u043B\u044E\u0447\u0435\u0439: src/certificates/server.jks","logger_name":"ru.billing.cardgate.server.CardServer","thread_name":"main","level":"INFO","level_value":20000,"HOSTNAME":"WKS-18384"}
{"@timestamp":"2016-09-22T14:04:40.974+03:00","@version":1,"message":"\u0417\u0430\u043F\u0443\u0441\u043A\u0430\u0435\u0442\u0441\u044F \u0441\u0435\u0440\u0432\u0435\u0440 \u043D\u0430 \u043F\u043E\u0440\u0442\u0443: 8090","logger_name":"ru.billing.cardgate.server.CardServer","thread_name":"main","level":"INFO","level_value":20000,"HOSTNAME":"WKS-18384"}
{"@timestamp":"2016-09-22T14:04:41.222+03:00","@version":1,"message":"\u041F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \u0441\u043B\u0443\u0448\u0430\u0435\u0442 \u043F\u043E\u0440\u0442: 8090","logger_name":"ru.billing.cardgate.server.CardServer","thread_name":"main","level":"INFO","level_value":20000,"HOSTNAME":"WKS-18384"}
{"@timestamp":"2016-09-22T14:04:41.223+03:00","@version":1,"message":"\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043E\u0434\u043D\u043E\u0432\u0440\u0435\u043C\u0435\u043D\u043D\u043E \u043E\u0431\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u043C\u044B\u0445 \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u0439: 2","logger_name":"ru.billing.cardgate.server.CardServer","thread_name":"main","level":"INFO","level_value":20000,"HOSTNAME":"WKS-18384"}   

I need to write logs in Russian. Help whoever knows please.

Sultan
  • 33
  • 2
  • 5

2 Answers2

1

Thought it was in the encoder tag.

<encoder class="net.logstash.logback.encoder.LogstashEncoder">
    <charset>UTF-8</charset>
</encoder>

The old log can be converted with the java tool; here to UTF-8.

ascii2native -encoding UTF-8 your.log >your_utf8.log
Joop Eggen
  • 107,315
  • 7
  • 83
  • 138
  • Unfortunetly, I could not solve this problem. But, I decided to cheat..) In my appender instead I wrote: ` {"@timestamp": "%d{yyyy-MM-dd'T'HH:mm:ss.SSS}","@message": "%m","logger_name": "%c","thread_name": "%t","level": "%p", "HOSTNAME": "%X{hostname}"}%n – Sultan Sep 28 '16 at 08:19
0

You should encode it to UTF-16, as it's required for cyrillic characters.

This answer is what you're looking for.

See for more details as your question actually a duplicate :

decode JSON with cyrillic characters

How to convert Strings to and from UTF8 byte arrays in Java

Community
  • 1
  • 1
Elcan
  • 814
  • 13
  • 27