当前位置:网站首页>[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*
边栏推荐
- The biggest highlight of wwdc2022: metalfx
- mysql中时间字段 比较时间大小
- How to write an amazing design document?
- RT thread simulator lvgl control: button button event
- 【硬记】脏读、不可重复读、幻读场景核心区别
- 基于ESP32CAM实现WebSocket服务器实时点灯
- RT-Thread 模拟器 simulator LVGL控件:button 按钮事件
- Detailed description of drawing ridge plot, overlapping densities of overlapping kernel density estimation curve, facetgrid object and function sns Kdeplot, function facetgrid map
- Sorting of numbers and strings
- 论文笔记: 多标签学习 BP-MLL
猜你喜欢

Oracle problem: the data in the field is separated by commas. Take the data on both sides of the comma

RT thread simulator lvgl control: switch switch button control

Paper notes: multi label learning bp-mll
![[Markov chain Monte Carlo] Markov chain Monte Carlo method sampling prior distribution](/img/8a/e6423168e110a168bc3cc6407628f6.png)
[Markov chain Monte Carlo] Markov chain Monte Carlo method sampling prior distribution

C语言:如何给全局变量起一个别名?

redis-3. Redis list, set, hash, sorted_ set、skiplist

C # related knowledge points

Compilation and development process of Quanzhi v3s environment

Test development programmers, are you still confused? You can't define yourself as a yard farmer

Ticdc introduction
随机推荐
Priority analysis of list variables in ansible playbook and how to separate and summarize list variables
Database connection under WinForm
论文笔记: 多标签学习 BP-MLL
No configure file found when compiling PHP from source code
通过函数seaborn.cubehelix_palette生成顺序调色板
Interview questions must be asked - Optimization of large table Pagination
Personal JS learning notes
redis-1. Install redis with pictures and texts
Paper notes: multi label learning bp-mll
Time field comparison time size in MySQL
C#合并多个richtextbox内容时始终存在换行符的解决方法
SDN basic overview
Nfv basic overview
RT-Thread 模拟器 simulator LVGL控件:switch 开关按钮控件
P1434 [SHOI2002] 滑雪 (记忆化搜索
在排序数组中查找元素的第一个和最后一个位置
微隔离(MSG)
考研英语
Word document export
First graphical interface