plog icon indicating copy to clipboard operation
plog copied to clipboard

Cannot use Plog with Crontab in Linux

Open HanshengGUO opened this issue 2 years ago • 2 comments

Hi,

I'm trying to use plog in my project and I need to use Crontab for scheduled automatic start. Here is my code

time_t t = time(0); 
char filename[100];
// The position for log file
strftime(filename, sizeof(filename), "/root/work/Lipschitz-future/iTradeDemo_Linux/log/%Y-%m-%d-%H:%M:%S.log",localtime(&t));
static plog::RollingFileAppender<plog::CsvFormatter> fileAppender(filename, 1000000, 5);
static plog::ConsoleAppender<plog::TxtFormatter> consoleAppender;
// Set 2 appenders to output to console and log file at same time
plog::init(plog::debug, &fileAppender).addAppender(&consoleAppender);

And I use Crontab to start it at a specific time. But the output is just one line (my program should output several lines) and then the program terminated.

Date;Time;Severity;TID;This;Function;Message
2023/02/21;20:01:03.038;INFO;26031;0;main@31;"Version iTapTradeAPI V9.3.2.1, Date 2019.9.17"

Would you please help me how I can use Plog and Crontab together?

HanshengGUO avatar Feb 21 '23 13:02 HanshengGUO

Hi!

Could you post the lines where do you write messages to the log?

SergiusTheBest avatar Feb 21 '23 13:02 SergiusTheBest

@HanshengGUO any updates?

SergiusTheBest avatar Mar 24 '23 17:03 SergiusTheBest