1

When I access xml, there is error message like this :

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

I want save the error message in log file

How to save xml error message in log file?

Thank you

Tim
  • 28,212
  • 8
  • 63
  • 76
moses toh
  • 12,344
  • 71
  • 243
  • 443

1 Answers1

0

You might want to look at file_put_contents() if you want something super quick:

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

Where "path to log file" is the path + name of the file you want to write to, and $stringInput is the string representation of the error. FILE_APPEND is a flag so that every time you call file_put_contents(), a new line gets added to the file rather than rewriting the file.

As an alternative, check out log5php which gives more control.

Stegrex
  • 4,004
  • 1
  • 17
  • 19
  • Thank you for answering my question. My case is like this. My code is like this : http://pastebin.com/vGSqiRbA. When I click button submit, I can access xml. But the xml display error message. How to save xml error message in log file? I still difficult to implement your answer. – moses toh Jan 21 '16 at 01:56
  • @mosestoh What does your PHP script look like? It should be whatever script is mapped to endpoint that's currently set as action="http://xxxxxxxxxxx" in the HTML you've pasted. Knowing what your PHP script looks like will let me understand what's going on. – Stegrex Jan 21 '16 at 04:30
  • It is a API url. I take the data from the url(Request) to get a response XML – moses toh Jan 21 '16 at 04:38