When you use -log command-line argument to start a dedicated server produced a single log file per server process. While the server is running the log file is appending. And even the server has working couple of days there is only one log file. It would be great if the log files were switched each day for example.
I’m not aware of any way to achieve what you’re describing with the built-in functionality or available command line options. However, I don’t think it would be too difficult to get something similar by writing a small Batch/Powershell/Python script that takes this multi-day log file and splits it into multiple files separated by date. You can then create it another script that is triggered when the server is shutdown, calls the log split script, and deletes the original log file. Hope that helps.
That’s correct, the log file will be locked by the running server and will be unlocked (for write access) when the server shuts down. However, you still have read access to the log file while the server is running, so you could make a copy of it at that moment in time and save it as Day1.log and save the current line index (say Day1.log is 511 lines). On the second day you can make another copy and then discard the first 511 lines before saving it as Day2.log and so on. Obviously this just an example of how to do it but it should give you an idea. Hope that helps.
There is no any problem when the server is shutted down. But what to do when the server is running?
For example the server is running for a week. I would like the server to open a new log file every day. Another way is a manually move log file to a different location (different name) and create new log file for server. But for now I could not change current log file because it locked by running server process.
You are absolutely right but the main problem I would like to solve is a huge size of current log file. And copying part of the log data didn’t solve it.
I understand. So you’re trying to split the big log file into smaller chunks so that you can periodically backup those files somewhere else and clear up space on the drive where the server is logging? I don’t think I have a solution in that case, since the only way to prevent the log file from growing too big is to stop the server and release the write lock on the file so that you can delete it. At least as far as I’m aware.
This is still a relevant issue. Will be great to have a solution. The game server should be permanently running, and logs need to be rotated. Did anyone solve this? Or is there anything in UE5 for this?