lechuck
lechuck

Reputation: 23

PoCo Logging. Log file name containing timestamp of creation OR New log file every time application starts

I need my program to start a new log file in each execution. I want to use PoCo as I am already using this library in the code.

From my point of view, I have two possibilities but I do not know how to configure any of them using a channel in Poco.

If I am not wrong, using FileChannel is not possible any these possibilities. I guess I could write a new PoCo channel but, obviously, I prefer something already working.

Does anybody have any idea for this. I tried to figure out using two channels but I do not see how.

thank you

Upvotes: 1

Views: 634

Answers (1)

Alex
Alex

Reputation: 5330

FileChannel has rotateOnOpen property. If you set this to true, it will create new file every time channel is opened. See FileChannel. If you do not have this property available, you are using an older version of Poco; in this case, you can simply open File channel with a newly generated name every time your application starts:

std::string name = yourCustomNameGenFunc(); 
AutoPtr<FileChannel> pChannel = new FileChannel(name);

Upvotes: 1

Related Questions