# How to Disable Operation Logging in Mole: A Complete Guide

> Easily disable operation logging in Mole by setting the MO_NO_OPLOG=1 environment variable. Follow this complete guide to stop Mole from creating operation logs.

- Repository: [Tw93/Mole](https://github.com/tw93/Mole)
- Tags: how-to-guide
- Published: 2026-03-20

---

**Set the environment variable `MO_NO_OPLOG=1` before running any Mole command to completely disable the operations log at `~/Library/Logs/mole/operations.log`.**

Operation logging in Mole, the open-source file management tool by tw93, records every filesystem change to an audit trail. While valuable for debugging and security auditing, you may need to disable operation logging in Mole for privacy reasons or when running automated scripts in sensitive environments.

## Understanding Mole's Operation Logging

### What Gets Logged

By default, Mole maintains a comprehensive operations log that captures every destructive command executed through the tool. This includes file deletions, moves, and other filesystem modifications performed via Mole's CLI interface.

### Default Log Location

The operations log is stored at:

```bash
~/Library/Logs/mole/operations.log

```

This path is hardcoded in the logging implementation at [`lib/core/log.sh`](https://github.com/tw93/Mole/blob/main/lib/core/log.sh), which handles all log file creation and writing operations.

## The MO_NO_OPLOG Environment Variable

### How It Works

The environment variable `MO_NO_OPLOG` serves as the primary control mechanism for disabling operation logging. According to the source code in [`lib/core/log.sh`](https://github.com/tw93/Mole/blob/main/lib/core/log.sh), the variable is checked at two critical points:

- **Line 32-33**: The log file is only opened when `MO_NO_OPLOG` is not equal to `1`
- **Line 73-74**: All logging functions early-exit when `MO_NO_OPLOG` equals `1`

This architecture ensures that when the variable is set to `1`, no filesystem operations related to logging are performed, completely bypassing the creation of `operations.log`.

### Configuration Values

| Value | Behavior |
|-------|----------|
| Not set or `0` | **Logging enabled** (default) - Creates and appends to `~/Library/Logs/mole/operations.log` |
| `1` | **Logging disabled** - No log file created or written |

## Methods to Disable Operation Logging

### Temporary Disable for Single Command

To disable operation logging for a single Mole command without affecting your shell environment, prefix the command with the variable assignment:

```bash
MO_NO_OPLOG=1 mole clean --dry-run

```

This approach is ideal for CI/CD pipelines, cron jobs, or one-off operations where you want to avoid log file generation without modifying your shell configuration.

### Permanent Disable via Shell Profile

To permanently disable operation logging across all Mole sessions, add the export statement to your shell's startup file:

```bash

# For Bash users, add to ~/.bashrc

export MO_NO_OPLOG=1

# For Zsh users, add to ~/.zshrc

export MO_NO_OPLOG=1

```

After editing the file, reload your shell configuration:

```bash
source ~/.bashrc  # or source ~/.zshrc

```

### Conditional Re-enabling

If you typically run with logging disabled but need to enable it for a specific debugging session, you can override the environment variable for that single command:

```bash
MO_NO_OPLOG=0 mole uninstall --debug

```

Setting the variable to any value other than `1` (or unsetting it entirely) restores the default logging behavior, causing Mole to resume writing to `~/Library/Logs/mole/operations.log`.

## Verification and Troubleshooting

### Checking Current Configuration

To verify whether operation logging is currently enabled or disabled in your environment, check the variable value:

```bash
echo $MO_NO_OPLOG

```

If the output is `1`, logging is disabled. If the output is empty or `0`, logging is active.

### Confirming Log File Status

After running Mole commands with `MO_NO_OPLOG=1`, confirm that no log file exists or that existing logs remain unmodified:

```bash
ls -la ~/Library/Logs/mole/operations.log

```

When properly disabled, either the file will not be created (for new installations) or the timestamp will remain unchanged from previous runs.

## Summary

- **Set `MO_NO_OPLOG=1`** to completely disable operation logging in Mole, preventing the creation of `~/Library/Logs/mole/operations.log`
- **Apply temporarily** by prefixing individual commands, or **permanently** by exporting the variable in your shell profile (`~/.bashrc` or `~/.zshrc`)
- **Implementation** resides in [`lib/core/log.sh`](https://github.com/tw93/Mole/blob/main/lib/core/log.sh) (lines 32-33 and 73-74), where the variable controls log file opening and write operations
- **Documentation** confirming this behavior appears in the project's [`README.md`](https://github.com/tw93/Mole/blob/main/README.md) and [`SECURITY_AUDIT.md`](https://github.com/tw93/Mole/blob/main/SECURITY_AUDIT.md) files

## Frequently Asked Questions

### Where is the Mole operations log stored?

The operations log is stored at `~/Library/Logs/mole/operations.log` on macOS systems. This path is hardcoded in the [`lib/core/log.sh`](https://github.com/tw93/Mole/blob/main/lib/core/log.sh) module, which handles all logging operations for the application.

### Will disabling operation logging affect Mole's functionality?

No, disabling operation logging by setting `MO_NO_OPLOG=1` does not affect Mole's core file management functionality. The variable only controls whether filesystem changes are recorded to the log file; all actual file operations (delete, move, clean, etc.) continue to work normally.

### Can I selectively disable logging for specific commands?

Yes, you can selectively disable logging for specific commands by prefixing only those commands with `MO_NO_OPLOG=1`. For example: `MO_NO_OPLOG=1 mole clean` will run the clean command without logging, while subsequent commands without the prefix will continue to log normally (unless you've set the variable permanently in your shell profile).

### How do I re-enable operation logging after disabling it?

To re-enable operation logging, either unset the environment variable using `unset MO_NO_OPLOG` or set it to any value other than `1` (such as `MO_NO_OPLOG=0`). If you added the export to your shell profile, remove or comment out that line, then reload your shell configuration with `source ~/.bashrc` (or `~/.zshrc`).