[comment]: # translation:outdated

[comment]: # ({new-475b92bc})
# Debug logging

To troubleshoot issues when working with Zabbix API, collecting data from Zabbix agent, or sending data to Zabbix server or proxy, you can enable debug logging.

The zabbix\_utils library uses Python's standard `logging` module.

To see detailed debug messages from the library:

1. Import Python's `logging` module in your script.
2. Configure the logging system to output messages in a readable format and set the logging level to DEBUG.

```python
import logging
from zabbix_utils import Getter

logging.basicConfig(
    format=u'[%(asctime)s] %(levelname)s %(message)s',
    level=logging.DEBUG
)

agent = Getter(host='127.0.0.1', port=10050)
resp = agent.get('system.uname')

print(resp.value)
```

With debug logging enabled, detailed information about requests and responses is printed, for example:

```bash
[2023-10-01 12:00:01,587] DEBUG Content of the packet: b'ZBXD\x01\x0c\x00\x00\x00\x00\x00\x00\x00system.uname'
[2023-10-01 12:00:01,722] DEBUG Zabbix response header: b'ZBXD\x01C\x00\x00\x00C\x00\x00\x00'
[2023-10-01 12:00:01,723] DEBUG Zabbix response body: Linux test_server 5.15.0-3.60.5.1.el9uek.x86_64
[2023-10-01 12:00:01,724] DEBUG Response from [127.0.0.1:10050]: Linux test_server 5.15.0-3.60.5.1.el9uek.x86_64
Linux test_server 5.15.0-3.60.5.1.el9uek.x86_64
```

[comment]: # ({/new-475b92bc})
