spdlog
spdlog copied to clipboard
How can I Set/Change the log rename in log rotation?
rotating log rename with index,but i want to replace it with datatime;
i want to replace it with datatime;
datetime? if so, you can use spdlog::sinks::daily_file_sink.
Wiki: https://github.com/gabime/spdlog/wiki/4.-Sinks
But what if you don't want a new file every day? Rotating file by size and then add the current timestamp to the freshly renamed file. That would be a great feature!
@jgreber Timestamp and index rotation are not supported.
See spdlog::sinks::rotating_file_sink rotation method.
Rotation is done by calculating the index to be given at the end of the file from max_files_.
https://github.com/gabime/spdlog/blob/81de01c02c2b49aa723806b0c1d557dd05721635/include/spdlog/sinks/rotating_file_sink-inl.h#L115-L137
If the timestamp is added to the filename, rotation will not be possible. This is because the timestamp set in the file will not be known when calculating the index.