-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Hi there!
We've stepped into a problem of an enormous one-context log file.
This doc says the following:
The log file is rotated per service run.
There were two files presented in the $env:SystemDrive\.onecontext directory:
- opennebula-context.log
- opennebula-context-old.log
So, I restarted the service — nothing happened. These two files had same content as before.
As I've discovered further, the current log rotation implementation is broken. Here's why.
Picture that you have opennebula-context.log file alone. If you restart the service, this piece of code is evaluated as "rotation":
# Move old logfile away - so we have a current log containing the output of the last boot
If ( Test-Path "$ctxDir\opennebula-context.log" ) {
mv "$ctxDir\opennebula-context.log" "$ctxDir\opennebula-context-old.log"
}
m
# Start now logging to logfile
Start-Transcript -Append -Path "$ctxDir\opennebula-context.log" | Out-Null
And it works... just once :)
Because the next time it would try mv log old.log it would do absolutely nothing, since this move operation throws an error like mv : Cannot create a file, it already exists. and the log messages keep going into the same log file which is getting bigger and bigger. And also there's single m character in the middle of the code, which is probably just a accidental misspell.
Whole situation can be fixed in a single if statement that just checks if old-log exist, and if so — deletes it. I will link a PR.
Or you may find a better and more complicated solution to implement proper rotation. Anyways, let get this fixed :)
Regards,
Veesiom.