Logging incoming sms messages

I need to write incoming sms messages to a syslog server but the received message is not viewable in the logs, only the receive notification.

From what I understand, one has to use the read sms function in the Tools->SMS menu to read the message.

Is there a way to write the received message to the log so that it can be passed to the syslog server OR, better yet, write the message directly into a remotely hosted MySQL database?

I have hunted for a solution but cannot find the answer. If someone could point me to documentation or provide an example script, I would be most grateful.

For others looking for a solution:
The command

 /tool sms inbox print

will return the contents of the received messages.

I used this in the API to return the results then saved the results to a MySQli database.