It would be great that V2Ray can keep a log file under certain size, and create a new file when the existing one reaches the limit.
for robust implementation, you should also monitor disk usage . I think deliver this work to syslog is a better choice(and less work).
agree with @pminmax945 , use log library with rotate support or send it to syslog.
maybe we can use Go's built-in timer and ticker features to rotate, backup and cleanup the logs.
In fact it's quite easy to implement with logrotate (almost all server os include it by default, and many softwares such as nginx depend on it).
Simple create a file /etc/logrotate.d/v2ray:
/absolute-path-to-log/*.log {
daily
size 100M # only rotate if file is larger than the size
missingok
rotate 10 # max old log files to keep. Older ones will be deleted
compress # compress to save space
delaycompress
notifempty
copytruncate # a tech to make app still able to write log to the old file. Otherwise, app may have to reopen log file after rotating
}
Nothing else needed.
See http://www.linuxcommand.org/man_pages/logrotate8.html for detailed usage of logrotate.
You can automatically setup it when installing or bundle a sample config file with released packages for the users' convenience.
Howerer logroate can not roate your log immediately when the log reach the max size,it run periodic as the time you config. So if v2ray write mass log in few hours, logreate has no help.
This task is now managed in Trello: https://trello.com/b/mxvCFrh6
Most helpful comment
In fact it's quite easy to implement with
logrotate(almost all server os include it by default, and many softwares such asnginxdepend on it).Simple create a file
/etc/logrotate.d/v2ray:Nothing else needed.
See http://www.linuxcommand.org/man_pages/logrotate8.html for detailed usage of
logrotate.You can automatically setup it when installing or bundle a sample config file with released packages for the users' convenience.