danieleteti/loggerpro

Question: PID and log rotation?

Closed this issue · 3 comments

luebbe commented

I could probably answer the question myself by looking at the code ;-), but:
How does the log rotation handle PIDs in filen ames, or how would it handle dates in file names (#66)?
If I start an application over and over again with a unique identifier in the log file name (PID, Date (kind of unique) :-), Date+Time, ...), would I get an infinite number of log files?
My expectation is that the log rotation should limit the number of created files by tag. So if I set the log rotation to ten and use a "unique" ID in the file name, the last ten starts of the application would be logged into separate files with a unique ID each.

PID in log file names has 2 utilization scenarios:

  • mantain log "by execution" avoiding log rotation in case of subsequent executions.
  • allow to use loggerpro when more than one instance is running (mostly in the case of desktop applications)

In all the other cases is not useful.

luebbe commented

Let's rephrase this:

  • Should there be a (configurable) limit on the number of log files created when the PID is used?
  • Could the log rotation parameter serve as the limit? E.g. log rotation is set to 10. A maximum of ten logs per execution is kept.

Log Rotation requires that the filename can be regenerated based only on "index". So the filename cannot depend on time.
About the PID the reason a a bit different. Log Rotation can rotate logs generated by the same "run" but cannot rotate logs generated by a previuos run. However, in the case of PID, this is what you need (don't overwrite log from a previous run), so it's OK.