To work out this sort of thing, you can always check the code. There are only 4 mentions of max_allowed_packet in the entire codebase, and the only one that is not in a string/comment is https://github.com/moodle/moodle/blob/master/lib/dml/mysqli_native_moodle_database.php#L1424
So, before inserting multiple rows in one big query (which I guess the logs code does) then it checks this to ensure that the MySQL settings are OK.
So, before inserting multiple rows in one big query (which I guess the logs code does) then it checks this to ensure that the MySQL settings are OK.