0

Boost.Log supports configurable file name, e.g. %Y_%m_%d_sample_%N.log. What I want is put them in different folders, say, "%Y_%m_%d/sample_%N.log", but it created a folder named "%Y_%m_%d", while I'm expecting "2011_05_02"(for the date I'm trying), do you know how to get what I want ? Thanks

Boaz Yaniv
  • 6,334
  • 21
  • 30
JQ.
  • 678
  • 7
  • 17

1 Answers1

1

It can't do this as it requires creating directories. Basically you can't create file dynamically in a non-existant directory at the OS level. That is why it parses the name you've configured and reuses dynamic template only for a filename and not for a directory. What you can do instead is probably to move those files to corresponding directories using few shell commands from a crontab.

SPDenver
  • 442
  • 5
  • 9
  • 1
    what a pity, I think it's implementable. Since they can create file on the fly, they should be able to create folders too. – JQ. May 10 '11 at 08:07
  • @JQ: It could still be implemented - with a custom backend (which is not that hard to implement, except that you'll probably have to reimplement all the log rolling behavior). You might even be able to hack the file_collector so that the files will *at least be collected* to different directories (depending on their date) after you've done with them. The easiest (and ugliest) way though, would be to simply copy Boost.Log's own backend and modify it to create directories on the fly, based on the filename pattern. – Boaz Yaniv May 11 '11 at 16:12