Have the Ruby logger create log files only if log messages exists

  Kiến thức lập trình

I want Ruby to log into a file, but only if there are acutally log messages. I don’t want to get empty log files without any messages.

I used the answer at Can I disable the log header for ruby logger? to keep Ruby from adding a header to the log file, but it is still being created, now without any content if there are no messages. How can I make Ruby to create the log file only if there are messages to log?

LEAVE A COMMENT