当前位置:网站首页>[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*
边栏推荐
- Micro isolation (MSG)
- socket编程2:IO复用(select && poll && epoll)
- C语言:如何给全局变量起一个别名?
- How worker threads in the thread pool are recycled
- RT-Thread 模拟器 simulator LVGL控件:button 按钮样式
- Real time lighting of websocket server based on esp32cam
- Learning notes of balanced binary tree -- one two pandas
- nodejs文件模块fs
- 量化框架backtrader之一文读懂Analyzer分析器
- 6. system call
猜你喜欢

WWDC2022最大的亮点: MetalFX

Real time lighting of websocket server based on esp32cam

Export chrome plug-ins and import local plug-ins to chrome

It's called the next generation monitoring system. Let's see how awesome it is

Micro isolation (MSG)

Test development programmers, are you still confused? You can't define yourself as a yard farmer
![[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

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

Department store center supply chain management system

Priority analysis of list variables in ansible playbook and how to separate and summarize list variables
随机推荐
Through the function seaborn cubehelix_ Palette build order palette
P6154 游走(记忆化搜索
First graphical interface (modified version)
Ticdc introduction
论文笔记: 多标签学习 BP-MLL
Why should two judgment expressions in if be written in two lines
FTP_ Manipulate remote files
Powerdispatcher reverse generation of Oracle data model
Nodejs file module FS
Login registration
Personal JS learning notes
It's called the next generation monitoring system. Let's see how awesome it is
Sorting of numbers and strings
About database: pgadmin4 editing SQL window
尝试使用RenderDoc查看UE的Shader代码
redis-5. Redis' RDB, fork, copyonwrite, AOF, RDB & AOF are mixed
Pdf to word
Performance tuning can't just depend on tapping the brain
How to stop PHP FPM service in php7
[turn to] FPGA interview questions