这是我从logback.xml文件中记录jsonl的追加器
<?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>
这是示例日志,请注意,西里尔文本是ascii代码。
{"@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"}
我需要用俄语写日志。帮助谁知道。
答案 0 :(得分:1)
以为它在编码器标签中。
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<charset>UTF-8</charset>
</encoder>
可以使用java工具转换旧日志;这里是UTF-8。
ascii2native -encoding UTF-8 your.log >your_utf8.log
答案 1 :(得分:0)
您应该将其编码为UTF-16,因为它是西里尔字符所必需的。
此answer是您正在寻找的。 p>
查看更多详细信息,因为您的问题实际上是重复的: