PuppyIP Resource Center
Network & Connection Troubleshooting 9 min Published 2026-11-17

Xray Debug Logs Fill a Linux Disk: Identify the Writer Before Cleanup

Xray debug logs can keep growing until they crowd a system disk. Identify the file Xray is writing before lowering verbosity or cleaning up one log.

Xray Debug log Linux disk full x-ui Log level Log cleanup

Service eligibility and regional restrictions

PuppyIP serves only compliant overseas businesses and their authorized personnel. Proxy services are not available in mainland China. The service may only be used for lawful business activities outside mainland China. Use of this service within mainland China is prohibited.

Hosting a proxy IP or server overseas does not change these restrictions. The service must not be provided to end users in mainland China through relaying, forwarding, sharing or resale. Before use, read the Terms of Service.

Key Takeaways

  • Use df on the target log path to inspect the filesystem containing that file. Use file size and available open-handle information to identify the writer instead of assuming the database or all logs are responsible.
  • For panel-managed Xray configuration, lower loglevel through the panel first; leaving debug enabled can increase log volume.
  • If space must be reclaimed, handle only one confirmed .log file after checking its identity, ruling out symlinks and preserving evidence that matters.
  • A missing Nezha Agent affects monitoring visibility, but does not by itself prove why Xray logs grew.

Determine whether the filesystem is full or one file is growing

When a Linux service reports database or disk is full, fails to write or shows a panel database error, first inspect the root filesystem and the directories consuming space. The cause may be logs, a database, backups, container layers or temporary files. Do not delete the database or clear every log directory just because the error appears in x-ui. Detailed Xray logs can grow under sustained traffic, but a multi-gigabyte file does not automatically mean it is safe to remove.

Use df for filesystem capacity, then du, stat and lsof to check directory size, the exact file size and its current writer. Diagnostic logs can contain client IPs, domains, inbound details or proxy metadata. Do not post complete logs, configuration or diagnostic bundles in public tickets.

Read-only checks for the log filesystem, Xray file and writer

These commands only read system state. Replace LOG with the confirmed Xray log path, then use df -h to inspect the mounted filesystem containing that file and check its size, type and open handles. Checking only df -h / can miss a separately mounted data disk or log partition. Directory scans can take time; if x-ui uses another data directory, follow the actual service configuration instead of rescanning the entire disk.

If lsof shows Xray writing the file, check the current logging level and configuration ownership through the service panel. If lsof is absent, this check does not identify the writer; do not install a new tool for this step. Use an existing process viewer or service logs if available, and keep the writer unconfirmed when it cannot be identified. If the log's filesystem still reports low space while the file is small, investigate other directories or deleted-but-open files rather than expanding the truncation scope.

Inspect the filesystem and one log file

sh
LOG='/usr/local/x-ui/REPLACE_WITH_CONFIRMED_LOG.log'
test -f "$LOG" && test ! -L "$LOG" || exit 1
df -h "$LOG"
stat -c '%s %n' -- "$LOG"
if command -v lsof >/dev/null 2>&1; then
  lsof "$LOG"
else
  printf 'lsof is not installed; this check cannot identify open writers without another existing process viewer\n'
fi
Run these read-only checks on the Linux host. Replace the path with the confirmed log file; df reports the filesystem containing it. If lsof is unavailable, the command states that this check cannot identify processes holding the file and does not install a tool.

Lower log verbosity first to limit further growth

If x-ui or another panel generates the Xray configuration, check the log level in that panel and select a less verbose level such as warning when continuous diagnosis is no longer needed. Do not directly edit a generated runtime file. Menu names and accepted values can vary by panel and core release; follow the active control panel and Xray documentation. Record the original value, keep a configuration backup and confirm whether applying the setting restarts Xray or briefly interrupts proxy connections.

Lowering the level can reduce future volume but does not shrink a file that has already grown. If diagnosis temporarily requires debug, set a clear end time and restore the normal level afterward; also check free space and the file's growth rate. Do not substitute indefinite debug logging, scheduled clearing of every log or an unverified generic logrotate rule for capacity management.

If space must be reclaimed, handle one verified log file

Truncating a log irreversibly removes its current contents. Decide whether the data is still needed for security review, troubleshooting or retention. If it is, first copy it to separate storage with controlled access and enough capacity, then verify that the copy is readable. Recheck the exact path, size and symlink status. Do not run wildcard cleanup against /var/log, /usr/local/x-ui or an entire log tree, and do not clear databases, configuration or subscription files.

The command below accepts one explicitly named regular .log file under the x-ui directory and reduces it to zero bytes. Replace the placeholder with the actual filename, confirm the contents are no longer needed and check the filesystem containing the target plus the safeguards above. There is no simple rollback after truncation; only a copy made beforehand can restore the original content. Check free space on the same filesystem and Xray state afterward.

Selectively clear one confirmed log

sh
LOG='/usr/local/x-ui/REPLACE_WITH_CONFIRMED_LOG.log'
case "$LOG" in /usr/local/x-ui/*.log) ;; *) echo 'Refusing path outside x-ui log files'; exit 1;; esac
test -f "$LOG" && test ! -L "$LOG" || { echo 'Refusing non-regular or symlink path'; exit 1; }
stat -c '%s %n' -- "$LOG"
truncate -s 0 -- "$LOG"
df -h "$LOG"
This loses data. Run only after the log no longer needs retention or a safe copy has been verified. Replace the path with one known x-ui .log file; df checks the filesystem containing that log after truncation. Do not widen it to a directory or wildcard.

After recovery, check the service, space and monitoring separately

After cleanup, confirm Xray's expected state in the service panel and check free space on the filesystem containing the target log. Observe whether the selected log keeps growing rapidly during a controlled period. If it does, investigate the log level, request volume, configuration and recurring errors instead of repeatedly clearing the file. If the file stops receiving data after truncation, check whether the panel rotates or recreates its log path.

A stopped host-monitoring service reduces visibility and disk alerts, but it is a separate check from the cause of log generation. If Nezha Agent is missing, independently verify its service state, authorized configuration and alert delivery; installing the agent is not an Xray log fix. Avoid rebooting the whole host without a backup and a service maintenance window.

Completion criteria and limits on rollback

After the change, confirm that the filesystem containing the log has enough usable space, Xray runs normally, the log level fits diagnostic needs and file growth is manageable. A database becoming writable shows that space pressure eased; it does not mean the previous log contents were preserved. If no copy exists, truncated contents cannot be recovered.

If you cannot identify the writer, prove that a path is an actual log, rule out a symlink or determine which panel manages the service, stop before cleanup. Xray releases, panel directories and log names vary. The path here is a placeholder example to replace, not a standard location for every installation.

Sources

Frequently Asked Questions

Can I delete the entire x-ui directory if Xray logs are large?

No. It may contain runtime configuration, a database, certificates or other service data. Identify one log file and its writer, then decide whether to preserve evidence or handle only that file.

Will lowering loglevel free the space already used?

No. It mainly reduces future log volume. Existing files need a separate retention and cleanup decision.

Can I use truncate on every .log file?

Do not clean them in bulk. Identify one exact log, assess retention needs and confirm the path is not a symlink. After truncation, only a copy made beforehand can restore the content.

Does a stopped Nezha Agent cause Xray logs to fill the disk?

That causal conclusion does not follow from the agent being stopped. It affects monitoring visibility; check Xray logging level, the actual writer and the monitoring service independently.