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

Torch Log Service

Copy page
Download PDF
LogCollector plugins
String replacement plugin
Copy page
Download PDF
String replacement plugin
You can use the replace plugin to perform string replacement on designated fields when collecting logs with LogCollector. This feature supports both regular expression matching and content matching.​
Notice​
  • This plugin is supported in LogCollector V1.0.34 and later versions. To view LogCollector version, see 2. View software version.​
  • The replace plugin can also be used in data masking scenarios to replace sensitive characters in specified fields with other strings, such as replacing the middle four digits of a phone number with ****. In this case, we recommend that you disable Upload parsing failure log and Upload original log to protect your sensitive information.​
Parameters description​
​
Name​
Type​
Required​
Description​
field​
String​
Yes​
Name of the field to be replaced.​
Field names must be unique and non-empty, and can not contain periods (.).​
type​
String​
Yes​
Log replacement methods Supported settings:​
  • string: Replace via string.​
  • regex: Replace via regular expressions.​
pattern​
String​
Yes​
Log content matching pattern. When there is one or more matches of the pattern in the original field, all of them will be replaced by the value corresponding to the replacement.​
  • If type is string, pattern should specify the log content as a string.​
  • If type is regex, pattern should specify the regular expression that matches the log content. Supports regular expression capture groups.​
replacement​
String​
Yes​
A string used to replace specified log content.​
when​
Object​
No​
The plugin execution condition. This plugin is executed only when the condition is evaluated as true. For more details, see Plugin execution conditions.​
ignore_missing​
Boolean​
No​
This parameter determines whether to ignore fields that do not exist.​
  • true (default): If no field exists, it is ignored.​
  • false: If no field exists, an error is reported.​
​
Configuration examples​
  • Key-value pair logs processed by collection mode or other processor plugins:​
  • ​
    "data": "Click Here"​
    "size": "36"​
    "style": "bold"​
    "name": "text1"​
    "hOffset": "250"​
    "vOffset": "100"​
    "alignment": "center"​
    "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"​
    "time": "Today is 2023-06-08. Tomorrow is 2023-06-09."​
    ​
  • LogCollector plugin processor configuration:​
  • ​
    {​
    "processors":[​
    {​
    "replace":[​
    {​
    "field":"alignment",​
    "type":"string",​
    "pattern":"en",​
    "replacement":"xx"​
    },​
    {​
    "field":"data",​
    "type":"regex",​
    "pattern":"[a-h]+",​
    "replacement":"xx"​
    }​
    ]​
    }​
    ]​
    }​
    ​
  • Processing result:​
  • ​
    "data": "Clixxk Hxxrxx"​
    "size": "36"​
    "style": "bold"​
    "name": "text1"​
    "hOffset": "250"​
    "vOffset": "100"​
    "alignment": "cxxter"​
    "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"​
    "time": "Today is 2023-06-08. Tomorrow is 2023-06-09."​
    ​
​
Last updated: 2025.12.12 10:30:52