I think we could avoid creating a console logfile at all in most conditions, and not worry about rotating it at all. Here's what I think should happen with the console logging:
- background, console NOT muted: redirect to console log.
- background, console muted: redirect to /dev/null.
- foreground: don't mute. Output to console, do not redirect or copy to console log.
I don't know whether the first condition would ever actually happen, but if it can happen, we could have console log rotation only in that situation, rotating the console log through a fixed and limited set of filenames where the oldest one is simply deleted.
The main log is rotated by log4j, but the script currently renames the active log on startup, so that a fresh log is always from server start. If a predictable string of text is logged only at service start and can be found with a backwards search from the end of the file, we might not need to have the script rename solr.log at startup. If log4j can do startup rotation, that would take care of the issue entirely.
I'll take your word on the GC log. I haven't looked into it.