plog
plog copied to clipboard
Cannot use Plog with Crontab in Linux
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?
Hi!
Could you post the lines where do you write messages to the log?
@HanshengGUO any updates?