There is a XenForo log file helper (Xenforo/Helper/File/log), but the file path/name isn't customizable, IIRC. It has to be in "internal_data".
I've use my own debug method and option in my addons, and my own log file helper for it.
It looks a little like this, nothing too fancy, you just send it the contents you want to write, and the status, such as "INFO", "ERROR", or whatever.
$this->debug is a flag indicating if a debug option is enabled.
$this->path is the absolute location to the log file.
If this is a batch type operation, then you can just use the 'a' to append to the log file on fopen(), or if you want to interrogate the file each time for an error, you could use "w" to rewrite the file each time.
Code:
public function write($logEntry, $status = "INFO")
{
if( !$this->debug )
{
return true;
}
if ($fp = @fopen($this->path, 'a'))
{
fwrite($fp, date('Y-m-d H:i:s') . ' | ' . $status . ' | ' . $logEntry . "\n");
fclose($fp);
return true;
}
return false;
}
}
Then if if you've instantiated a $log object, I just do:
$log->write("This is the log entry");
or
$log->write("Woah, something just got manhandled", "ERROR");