You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
Data processing best practices
Data masking
Copy page
Download PDF
Data masking
TLS DSL offers a regular expression replacement function. You can hide sensitive data in logs by using regex replacements, which reduces the risk of sensitive data leakage.​
Phone number masking​
To desensitize a phone number, you can use the regex replacement function to substitute the middle digits of a phone number with specified characters. For example, use the regex_replace function to replace the middle four digits of an 11-digit phone number, so the full number is not displayed.​
Raw log​
​
[​
{​
"phone":"15199997654"​
}​
]​
​
DSL processing rules​
​
# Use regular expressions for replacement​
f_set("phone", regex_replace(v("phone"), "(\\d{0,3})\\d{4}(\\d{4})", replace="$1****$2"))​
​
Processing result​
​
[​
{​
"phone":"151****7654"​
}​
]​
​
IP address masking​
To achieve IP address masking, you can use the regex replacement function to substitute the middle digits of an IP address with a specified character. For example, if a log contains an IP address, you can use the regex_replace function to identify and mask the IP address with regular expressions.​
Raw log​
​
[​
{​
"ip":"111.222.111.222"​
}​
]​
​
DSL processing rules​
​
# Use regular expressions for replacement​
f_set("ip", regex_replace(v("ip"), "(\\d+).(\\d+).(\\d+).(\\d+)", replace="$1.*.*.$4"))​
​
Processing result​
​
[​
{​
"ip":"111.*.*.222"​
}​
]​
​
Email address masking​
To achieve email address masking, you can use a regular expression replacement function to replace the prefix of an email address with specified characters. For example, if the following log contains a complete email address, you can replace the prefix of the email address so that all characters except the first are replaced with *. Through this method, the displayed email address will not be shown as full address.​
Raw log​
​
[​
{​
"mail":"seo1893@dev.com"​
}​
]​
​
DSL processing rules​
​
# Use regular expressions for replacement​
f_set("mail", regex_replace(v("mail"), "([A-Za-z\d])[A-Za-z\d]+(@.*)", replace="$1***$2"))​
​
Processing result​
​
[​
{​
"mail":"s***@dev.com"​
}​
]​
​
​
Last updated: 2026.03.16 11:00:11