If it's available in your version, you can accomplish this by sending a message from the client to the gateway using system.util.sendMessage and then logging it there. See screenshot of gateway message handler in linked post below:
The client sends a message with with loggerName, level, and message and the gateway logs it accordingly.