Logging

self.logger

Each service has access to the self.logger object which is an instance of a Python stdlib’s logging.Logger class.

1
2
3
4
5
6
from zato.server.service import Service

class MyService(Service):

    def handle(self):
        self.logger.info('handle called')

The message will be written to the logs though where to exactly depends on how a server has been configured by administrators - by default messages are written to local log files called server.log but the exact location or locations can be set to anything Python's logging library supports, including syslog, e-mail or ZeroMQ sockets.

Additionally, each service offers the log_input and log_output convenience methods to simplify the task of logging the IO.

SQL

As a special aid during development, one can exploit the fact that SQLAlchemy, the toolkit Zato uses for connecting to SQL databases, allows one to echo all the statements issued if one passes an 'extra=True' flag when the connection is established.

In practical terms, it means that adding line to a server.conf such as

[odb]
extra=echo=True

will make SQLAlchemy output all the SQL queries to server logs on the DEBUG level.