如何在日志文件中保存 xml 错误消息


How to save xml error message in log file?

当我访问xml时,出现如下错误消息:

<ErrorMSG>Credit limit exceed. Booking cannot be proceed. </ErrorMSG></Response>

我想将错误消息保存在日志文件中

如何在日志文件中保存xml错误消息?

谢谢

如果你想要一些超快的东西,你可能想看看file_put_contents():

file_put_contents('<path to log file>', $stringInput, FILE_APPEND);

其中"日志文件路径"是要写入的文件的路径 + 名称,$stringInput是错误的字符串表示形式。FILE_APPEND是一个标志,因此每次调用 file_put_contents() 时,都会向文件添加新行,而不是重写文件。

作为替代方案,请查看log5php,它提供了更多的控制。