reference Environment variables

OPENGREP_LOG_FILE

Also spelled
SEMGREP_LOG_FILE
Value
a file path
See also
--debug, --verbose, OPENGREP_LOG_LEVEL

A file that receives a copy of the logs that Opengrep writes to standard error, at the same level. At the default level, these are the warnings and the summary; --verbose, --debug and OPENGREP_LOG_LEVEL raise the level for both. Standard error is not affected.

The file is truncated at the start of each run, and missing directories on its path are created. When the file cannot be created, Opengrep logs the warning cannot write the log file of $OPENGREP_LOG_FILE and runs without it.

Examples

Keeping the verbose logs

rule.yaml
rules:  - id: find-eval    pattern: eval(...)    message: found eval    languages: [python]    severity: WARNING
app.py
eval(1)
Command and result
$ OPENGREP_LOG_FILE=logs/scan.log opengrep scan --config rule.yaml --verbose app.py > /dev/null 2>&1
$ head -2 logs/scan.log
[00.04][INFO]: Opengrep version: X.Y.Z
[00.04][INFO]: Getting the rules
$ OPENGREP_LOG_FILE=/dev/null/scan.log opengrep scan --config rule.yaml app.py 2>&1 >/dev/null | grep -oF 'cannot write the log file of $OPENGREP_LOG_FILE'
cannot write the log file of $OPENGREP_LOG_FILE