当前位置:网站首页>[log4j2 log framework] sensitive character filtering
[log4j2 log framework] sensitive character filtering
2022-06-13 07:26:00 【Small side good side】
0、 background
zookeeper The logging framework used by the server was replaced by log4j2,zk Of sessionid It is also evaluated as sensitive information by the big man in charge of security , Can't print directly , So we should think of a quick solution without modifying the source code sessionid Print the method of shielding .
1、log4j2 Of replace function
Many logging frameworks have the function of filtering and replacing ,log4j2 No exception , Support regular substitution .
First look at zk Of sessionid Generation method 
sessionid High order for service id, In the middle is the timestamp , The low order is an increasing sequence , The maximum value is Long The maximum of .
log4j2.properties Of pattern Add regular expression in
appender.rolling.layout.pattern = %d %p %c{
1.} [%t] %replace{
%msg}{
0x[a-f0-9]{
15,}|0x0}{
0x*} -%replace{
%ex}{
0x[a-f0-9]{
15,}|0x0}{
0x*}%n
appender.rolling.layout.alwaysWriteExceptions=false
It's not just replace 了 msg, also replace 了 ex, because log4j2 Exceptions in are distinguished separately , Both the normal log and the exception log may appear sessionid, So at the same time msg and ex To configure replace.appender.rolling.layout.alwaysWriteExceptions On by default , Since it's already in pattern Configuration of the ex It's going to close alwaysWriteExceptions.
Finally, it perfectly replaces all sessionid by 0x*
边栏推荐
- AQS - detailed explanation of reentrantlock source code
- 【ViveFocus使用WaveVR插件获取手柄操作事件】
- [hard copy] core differences among dirty reading, non repeatable reading and unreal reading scenarios
- Un des backtraders du cadre de quantification lit l'analyseur
- EF CORE执行SQL语句
- 5. interrupts and exceptions
- [RS-422 and RS-485] RS-422 and RS-485 serial interface standard
- 考研英语
- C # related knowledge points
- Simple understanding of basic language of C language
猜你喜欢

Department store center supply chain management system

平衡二叉树学习笔记------一二熊猫

Evolution in the digital age

Socket programming 2:io reuse (select & poll & epoll)

Learning notes of balanced binary tree -- one two pandas

socket编程2:IO复用(select && poll && epoll)

WWDC2022最大的亮点: MetalFX

Calculate running total / running balance

Implementation of fruit mall wholesale platform based on SSM

RT-Thread 模拟器 simulator LVGL控件:switch 开关按钮控件
随机推荐
理财产品连续几天收益都是零是怎么回事?
【ViveFocus使用WaveVR插件获取手柄操作事件】
Export chrome plug-ins and import local plug-ins to chrome
JMeter encryption interface test
Tree list under winfrom treelist related
Socket programming 2:io reuse (select & poll & epoll)
Mui mixed development - when updating the download app, the system status bar displays the download progress
How to use clion to debug a project built by the make tool
redis-3. Redis list, set, hash, sorted_ set、skiplist
What does my financial product mean in clearing?
How to stop PHP FPM service in php7
RT thread simulator lvgl control: button button style
The biggest highlight of wwdc2022: metalfx
powerdisgner逆向生成oracle数据模型
C#合并多个richtextbox内容时始终存在换行符的解决方法
Ticdc introduction
10. process communication
Wechat applet - positioning, map display, route planning and navigation
P1434 [show2002] skiing (memory search
The management practice of leading enterprises has proved that what is the core of sustainable development of enterprises?