I want to remove from api.log file the authorization header that appears there:
[2022-02-08 15:00:57,703] INFO {API_LOG} pizzashack - {"headers":["accept=application/json",...,"Connection=keep-alive","Host=localhost:8243","authorization=Bearer yJraWQiOiJnYXRld2F5X3g...","Origin=https://localhost:9443"..
I want to delete that token inside authorization header, how can i do it? I have tried with log4jproperties adding:
logger.API_LOGGER.property.apim.message = %replace{%msg}{authorization:[^,]*}{"Authorization: Bearer ***"}{}
But it gives me an error when restarting APIM.
You should be able to do this using log-masking[1].
A sample config is shown below.
[masking_pattern.properties]
"JWT" = ' \\b([a-zA-Z0-9_=]+)\\.([a-zA-Z0-9_=]+)\\.([a-zA-Z0-9_\\-\\+\\/=]*)\\"'
appender.API_LOGFILE.layout.pattern = [%d] %5p {%c} %X{apiName} - %mm%ex%n