Access log truncating #3915
-
I am using xray 24.9.30 as a dependency of 3x-ui panel. I am experiencing a problem with access.log truncated approximately every hour (at HH:14). I.e. it contiguously contains entire log, but at some point it resets and starts from the clear file. It seems to be some stupid misconfiguration, but I don't know how to debug that. More info in screenshot (daemon is started more then a day). |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Have same ptroblem. @brazhenko Have you managed to deal with this problem? |
Beta Was this translation helpful? Give feedback.
-
Hello, @marchuk-vlad @brazhenko Have you managed to resolve the issue with access.log being truncated approximately every hour (at HH:14)? If so, could you share how you fixed it? I'm facing the same problem in my setup with 3x-ui and Xray. |
Beta Was this translation helpful? Give feedback.
-
Hello @brazhenko @marchuk-vlad , I've also been looking into the issue of access logs being cleared periodically and have done some analysis of the source code. Here are my findings, which should answer the question. This behavior is indeed by design and is related to a scheduled task within the application. 1. Where is the log clearing logic? The logic for clearing the access log is part of a scheduled job found in The specific function that performs the clearing is 2. The Code That Clears the Log The log file is cleared using // web/job/check_client_ip_job.go
func (j *CheckClientIpJob) clearAccessLog() {
// ... code to back up the log ...
// This line truncates the access log file, effectively clearing it.
err = os.Truncate(accessLogPath, 0)
j.checkError(err)
j.lastClear = time.Now().Unix()
} 3. How is the persistent log file path configured? The path for the persistent log file (
So, the final path is either // config/config.go
func GetLogFolder() string {
logFolderPath := os.Getenv("XUI_LOG_FOLDER")
if logFolderPath == "" {
logFolderPath = "/var/log"
}
return logFolderPath
}
// xray/process.go
func GetAccessPersistentLogPath() string {
return config.GetLogFolder() + "/3xipl-ap.log"
} 4. Why is it designed this way? (Speculation) This design appears to be a log rotation and management strategy. The primary purposes are likely:
Currently, the one-hour interval is hardcoded and cannot be changed from the panel UI. To modify it, you would need to change the I hope this detailed explanation helps others who have the same question! |
Beta Was this translation helpful? Give feedback.
-
I got the same results as yours, but had no time to leave it here. Marked as answer. All I can suggest which also works for me is to configure custom logrotate.
|
Beta Was this translation helpful? Give feedback.
Hello @brazhenko @marchuk-vlad , I've also been looking into the issue of access logs being cleared periodically and have done some analysis of the source code. Here are my findings, which should answer the question.
This behavior is indeed by design and is related to a scheduled task within the application.
1. Where is the log clearing logic?
The logic for clearing the access log is part of a scheduled job found in
web/job/check_client_ip_job.go
. This job runs every 10 seconds, but it only clears the log if more than an hour (3600 seconds) has passed since the last time it was cleared.The specific function that performs the clearing is
clearAccessLog()
within the same file. Before clear…