问题
What php code should I use in a Prestashop module to write to a log file? I have used
Logger::addLog("something",1);
but it does not work.
回答1:
You can also store the log in file using below code.
$logger = new FileLogger(0); //0 == debug level, logDebug() won’t work without this.
$logger->setFilename(_PS_ROOT_DIR_.”/log/debug.log”);
$logger->logDebug(“message 1″);
$logger->logDebug(“message 2″);
It will work!.
Thanks
回答2:
The log is saved in database in 'log' table (with your current prefix);
回答3:
Another alternative is to use PHP's
file_put_contents(_PS_ROOT_DIR_ . '/path/to/logfile',
$data . "\n",
FILE_APPEND);
来源:https://stackoverflow.com/questions/16132637/prestashop-how-do-i-write-to-a-log-file