spdlog icon indicating copy to clipboard operation
spdlog copied to clipboard

Custom filename creation for all sinks

Open ldionne opened this issue 7 years ago • 10 comments

Currently, I think only the daily logger allows customizing the filename format. I'm trying to replace our internal logging framework by Spdlog, and I need to encode the date in the filename (but without using a daily logger, which is too coarse grained). Instead, I want to generate a new filename every time a size-based sink "rotates". I might be able to provide a PR if there's interest for solving this issue.

ldionne avatar Dec 15 '17 00:12 ldionne

Thanks. That would be useful.

gabime avatar Dec 15 '17 00:12 gabime

Do we have an example of how to achieve this?

shazni avatar Dec 25 '17 16:12 shazni

Do we have an example of how to achieve this?

The daily sink already has such possibility

gabime avatar Dec 25 '17 16:12 gabime

How is the progress on this issue?

fawdlstty avatar Feb 02 '21 09:02 fawdlstty

I need this feature as well - specifically using "datetime" instead of "index" suffix for rotated files - similar to that provided by logrotate dateformat with second resolution.

Is there any progress on this issue or a suggested workaround to achieve this?

alokpr avatar May 21 '21 18:05 alokpr

https://github.com/gabime/spdlog/pull/1847 Does this PR solve this problem?

fawdlstty avatar May 22 '21 03:05 fawdlstty

IIUC daily sink only rotates daily. I need file size based rotation.

alokpr avatar May 22 '21 05:05 alokpr

I also need this feature. Is there any general schedule regarding this topic?

KonradJPE avatar Jun 23 '21 05:06 KonradJPE

I would need this feature as well for size based rotation

rhaport avatar Sep 27 '21 09:09 rhaport

Any updates to the issues?:

  1. allow file syncs to customize file names (e.g. add process name, add timestamp, etc.) - although it was stated that the daily file sink can do this I see no example of this via config file. the daily file sink appends the year/month/day to the file name automatically ... it is not customizable from a config file from what we can tell?! what are we missing? how is this done through config file?
  2. rotate file based on filesize - is this working? how is this done through config file?
  3. create new log on process crash - how is this done through config file? Thanks!

twarg1 avatar Jan 14 '22 04:01 twarg1