Masking Email Addresses in Lnav for Secure Log Viewing
The log file is open, raw, and dangerous. Email addresses sit in plain sight, exposed to anyone with read access. One breach, one careless copy, and personal data is gone.
Lnav gives you the tools to fix this without rewriting your application or cleaning logs by hand. Its masking features let you hide sensitive data — including email addresses — directly in the viewer. No permanent change to the source logs. No delay in analysis. Just safe, visible patterns without the sensitive bits.
Masking emails in Lnav starts with defining a regular expression that matches addresses. For example:
:config set regex email_mask "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
Then, tell Lnav to replace matches with a placeholder:
:config set regex-sub email_mask "[EMAIL_MASKED]"
From that moment, every email address in your logs is replaced in the view before reaching your eyes. Search still works on patterns. Context remains intact. Logged events stay readable. You reduce your data risk without losing operational clarity.
Because Lnav processes this masking at display time, you don’t have to touch original files. The raw data can remain in secure storage where access is limited. Your daily analysis, alerts, and debugging sessions can run with masked output. Compliance and privacy controls become part of your log reading workflow, not an afterthought.
This approach scales. You can mask more than emails. API keys, session IDs, or any sensitive tokens can vanish from view instantly. One config, permanent safety in interactive log review.
Stop leaving email addresses exposed in logs. With Lnav masking, you control what’s visible every time you open a file. See it live in minutes at hoop.dev and build secure, private logging into your workflow now.