当前位置:网站首页>[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*
边栏推荐
- RT thread simulator lvgl control: slider control
- C Advanced Programming - features
- SDN basic overview
- Calculate running total / running balance
- oracle问题,字段里面的数据被逗号隔开,取逗号两边数据
- How worker threads in the thread pool are recycled
- RT-Thread 模拟器 simulator LVGL控件:switch 开关按钮控件
- Sharp weapon tcpdump
- 汇编语言基础:寄存器和寻址方式
- 25个国内外文献数据库
猜你喜欢
Try to use renderdoc to view the shader code of UE
Detailed description of drawing ridge plot, overlapping densities of overlapping kernel density estimation curve, facetgrid object and function sns Kdeplot, function facetgrid map
Micro isolation (MSG)
Calculate running total / running balance
Lightning breakpoint continuation
【ViveFocus使用WaveVR插件获取手柄操作事件】
Three handshakes and four waves of TCP protocol and why------ One two pandas
[Markov chain Monte Carlo] Markov chain Monte Carlo method sampling prior distribution
C # related knowledge points
Learning notes of balanced binary tree -- one two pandas
随机推荐
Paper notes: multi label learning bp-mll
检测循环数“142857“
Through the function seaborn cubehelix_ Palette build order palette
How to stop PHP FPM service in php7
MySQL does not recommend setting the column default value to null. Why on earth is this
How to solve the 404 problem
[weak transient signal detection] matlab simulation of SVM detection method for weak transient signal under chaotic background
Interview questions must be asked - Optimization of large table Pagination
RT-Thread 模拟器 simulator LVGL控件:button 按钮样式
关于c#委托、事件相关问题
How is it that the income of financial products is zero for several consecutive days?
c#高级编程-特性篇
redis-3. Redis list, set, hash, sorted_ set、skiplist
部署RDS服务
Related operations under Oracle Database
6. system call
redis-5. Redis' RDB, fork, copyonwrite, AOF, RDB & AOF are mixed
【ViveFocus使用WaveVR插件获取手柄操作事件】
8. process status and transition
Quick sort