栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

loggie 编码以及换行符测试

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

loggie 编码以及换行符测试

一、测试非编码单行换行符

1、测试场景

rn测试

pipeline配置文件:

pipelines:
  - name: local
    sources:
      - type: file
        name: demo
        lineEnd:
          type: carriage_return_line_feed
          value: "rn"
          charset: utf-8
        paths:
          - /home/zhanglei/*.log
        fields:
          topic: "loggie"
    interceptors:
      - type: iconv
        charset: "utf-8"
    sink:
      type: dev
      printEvents: true
      codec:
        pretty: true
2、测试脚本
 
3、测试结果 

输出正常

二、测试编码单行换行符 1、测试场景

gbk 编码

rn测试

pipeline配置文件:

pipelines:
  - name: local
    sources:
      - type: file
        name: demo
        lineEnd:
          type: carriage_return_line_feed
          value: "rn"
          charset: gbk
        paths:
          - /home/zhanglei/*.log
        fields:
          topic: "loggie"
    interceptors:
      - type: iconv
        charset: "gbk"
    sink:
      type: dev
      printEvents: true
      codec:
        pretty: true

2.测试脚本
 

3.测试结果

三、测试非编码 auto 换行符 1、测试场景

n测试

pipeline配置文件:

pipelines:
  - name: local
    sources:
      - type: file
        name: demo
        lineEnd:
          type: auto
        paths:
          - /home/zhanglei/*.log
        fields:
          topic: "loggie"
    interceptors:
      - type: iconv
    sink:
      type: dev
      printEvents: true
      codec:
        pretty: true

2.测试脚本
 

3.测试结果

 四、测试编码 auto 换行符 1、测试场景

gbk 编码

n测试

pipeline配置文件:

pipelines:
  - name: local
    sources:
      - type: file
        name: demo
        lineEnd:
          type: auto
          value: "rn"
          charset: gbk
        paths:
          - /home/zhanglei/*.log
        fields:
          topic: "loggie"
    interceptors:
      - type: iconv
        charset: "gbk"
    sink:
      type: dev
      printEvents: true
      codec:
        pretty: true

2.测试脚本
 

3.测试结果

五、测试非编码自定义换行符(特殊字符) 1、测试场景

pipeline:

pipelines:
  - name: local
    sources:
      - type: file
        name: demo
        lineEnd:
          type: custome
          value: "rn"
        paths:
          - /home/zhanglei/*.log
        fields:
          topic: "loggie"
    interceptors:
      - type: iconv
    sink:
      type: dev
      printEvents: true
      codec:
        pretty: true
2、测试结果

3、结论

custom 配置不能解决 特殊ascii码问题 

特殊字符使用

	lineTerminators = map[string]LineTerminator{
		"auto":                      AutoLineTerminator,
		"line_feed":                 LineFeed,
		"vertical_tab":              VerticalTab,
		"form_feed":                 FormFeed,
		"carriage_return":           CarriageReturn,
		"carriage_return_line_feed": CarriageReturnLineFeed,
		"next_line":                 NextLine,
		"line_separator":            LineSeparator,
		"paragraph_separator":       ParagraphSeparator,
		"null_terminator":           NullTerminator,
	}
六、测试非编码自定义换行符(非特殊字符) 1、测试场景

pipeline:

pipelines:
  - name: local
    sources:
      - type: file
        name: demo
        lineEnd:
          type: custom
          value: "的"
        paths:
          - /home/zhanglei/*.log
        fields:
          topic: "loggie"
    interceptors:
      - type: iconv
    sink:
      type: dev
      printEvents: true
      codec:
        pretty: true
2、测试结果

3、结论

正常

 七、测试编码自定义换行符(特殊字符) 1、测试场景

pipeline:

pipelines:
  - name: local
    sources:
      - type: file
        name: demo
        lineEnd:
          type: custom
          value: "rn"
          charset: gbk
        paths:
          - /home/zhanglei/*.log
        fields:
          topic: "loggie"
    interceptors:
      - type: iconv
        charset: gbk
    sink:
      type: dev
      printEvents: true
      codec:
        pretty: true
2、测试结果

3、结论

custom 配置不能解决 特殊ascii码问题 

但是可见字符都是正常的,如果出现不可见字符请使用

	lineTerminators = map[string]LineTerminator{
		"auto":                      AutoLineTerminator,
		"line_feed":                 LineFeed,
		"vertical_tab":              VerticalTab,
		"form_feed":                 FormFeed,
		"carriage_return":           CarriageReturn,
		"carriage_return_line_feed": CarriageReturnLineFeed,
		"next_line":                 NextLine,
		"line_separator":            LineSeparator,
		"paragraph_separator":       ParagraphSeparator,
		"null_terminator":           NullTerminator,
	}

解码后出现bug

 八、测试编码自定义换行符(非特殊字符) 1、测试场景

pipeline:

pipelines:
  - name: local
    sources:
      - type: file
        name: demo
        lineEnd:
          type: custom
          value: "rn"
          charset: gbk
        paths:
          - /home/zhanglei/*.log
        fields:
          topic: "loggie"
    interceptors:
      - type: iconv
        charset: gbk
    sink:
      type: dev
      printEvents: true
      codec:
        pretty: true
2、测试结果

3、结论

非特殊字符解码正常

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/984694.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号