Skip to content

Log levels don't work properly in examples #2901

Description

@KevinWMatthews

Versions

  • Python: 3.14
  • OS: MacOS
  • Pymodbus: 3.12.1
  • Modbus Hardware (if used): None

Pymodbus Specific

  • Server: tcp - async
  • Client: tcp - async

Description

I am running the async client / server examples. I expect to see INFO level logs and do not see most/any of them.

Additionally, the CLI option --log has little effect.

Code and Logs

Info Level

Setup:

% cd pymodbus/examples
% python3 -m venv .venv
% source .venv/bin/activate

For the server:

(.venv) % python3 server_async.py
2026-03-11 22:28:43,163 INFO  base:89 Server listening.

For the client:

(.venv) % python3 client_async.py
# no output

Notably:

  • __file__ had no impact on logger configuration; it is omitted entirely
  • no INFO level statements appear in client logs, though they are implemented

Debug Level

Setup:

% cd pymodbus/examples
% python3 -m venv .venv
% source .venv/bin/activate

For the server:

(.venv) % python3 server_async.py --log debug
2026-03-11 22:31:18,206 DEBUG transport:265 Awaiting connections server_listener
2026-03-11 22:31:18,209 INFO  base:89 Server listening.
2026-03-11 22:31:28,529 DEBUG transport:287 Connected to server
2026-03-11 22:31:28,630 DEBUG transport:339 recv: 0x0 0x1 0x0 0x0 0x0 0x6 0x1 0x1 0x0 0x20 0x0 0x1 extra data:
2026-03-11 22:31:28,630 DEBUG base:72 Processing: 0x0 0x1 0x0 0x0 0x0 0x6 0x1 0x1 0x0 0x20 0x0 0x1
2026-03-11 22:31:28,631 DEBUG decoders:77 decoded PDU function_code(1 sub -1) -> ReadCoilsRequest(dev_id=0, transaction_id=0, address=32, count=1, bits=[], registers=[], status=1, retries=0)
2026-03-11 22:31:28,631 DEBUG transport:393 send: 0x0 0x1 0x0 0x0 0x0 0x4 0x1 0x1 0x1 0x1
2026-03-11 22:31:28,631 DEBUG transport:339 recv: 0x0 0x2 0x0 0x0 0x0 0x6 0x1 0x3 0x0 0x4 0x0 0x2 extra data:
2026-03-11 22:31:28,631 DEBUG base:72 Processing: 0x0 0x2 0x0 0x0 0x0 0x6 0x1 0x3 0x0 0x4 0x0 0x2
2026-03-11 22:31:28,631 DEBUG decoders:77 decoded PDU function_code(3 sub -1) -> ReadHoldingRegistersRequest(dev_id=0, transaction_id=0, address=4, count=2, bits=[], registers=[], status=1, retries=0)
2026-03-11 22:31:28,632 DEBUG transport:393 send: 0x0 0x2 0x0 0x0 0x0 0x7 0x1 0x3 0x4 0x0 0x11 0x0 0x11
2026-03-11 22:31:28,632 DEBUG transport:356 -> transport: received eof
2026-03-11 22:31:28,632 DEBUG transport:299 Connection lost server due to None
2026-03-11 22:31:28,632 DEBUG requesthandler:49 Handler for stream [server] has been canceled

For the client:

(.venv) % python3 client_async.py --log debug
2026-03-11 22:31:28,528 DEBUG base:56 Connecting to 127.0.0.1:5020.
2026-03-11 22:31:28,528 DEBUG transport:251 Connecting comm
2026-03-11 22:31:28,529 DEBUG transport:287 Connected to comm
2026-03-11 22:31:28,630 DEBUG transport:393 send: 0x0 0x1 0x0 0x0 0x0 0x6 0x1 0x1 0x0 0x20 0x0 0x1
2026-03-11 22:31:28,631 DEBUG transport:339 recv: 0x0 0x1 0x0 0x0 0x0 0x4 0x1 0x1 0x1 0x1 extra data:
2026-03-11 22:31:28,631 DEBUG base:72 Processing: 0x0 0x1 0x0 0x0 0x0 0x4 0x1 0x1 0x1 0x1
2026-03-11 22:31:28,631 DEBUG decoders:77 decoded PDU function_code(1 sub -1) -> ReadCoilsResponse(dev_id=0, transaction_id=0, address=0, count=0, bits=[True, False, False, False, False, False, False, False], registers=[], status=1, retries=0)
2026-03-11 22:31:28,631 DEBUG transport:393 send: 0x0 0x2 0x0 0x0 0x0 0x6 0x1 0x3 0x0 0x4 0x0 0x2
2026-03-11 22:31:28,632 DEBUG transport:339 recv: 0x0 0x2 0x0 0x0 0x0 0x7 0x1 0x3 0x4 0x0 0x11 0x0 0x11 extra data:
2026-03-11 22:31:28,632 DEBUG base:72 Processing: 0x0 0x2 0x0 0x0 0x0 0x7 0x1 0x3 0x4 0x0 0x11 0x0 0x11
2026-03-11 22:31:28,632 DEBUG decoders:77 decoded PDU function_code(3 sub -1) -> ReadHoldingRegistersResponse(dev_id=0, transaction_id=0, address=0, count=0, bits=[], registers=[17, 17], status=1, retries=0)

Notably:

  • __file__ had no impact on logger configuration; it is omitted entirely
  • no INFO level statements from server_async.py appear, though they are implemented
  • no INFO level statements from client_async.py appear, though they are implemented

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions