Do I have to log IP addresses for possible criminal investigations? Do I have to be compliant in terms of GDPR for the subject of IP logging (as IP considerable to be an "online identifier", a GDPR term)?
Generally speaking, no, although you did not specify the type of online service at issue.
To the extent that "[n]atural persons may be associated with online identifiers [...] such as internet protocol addresses" (see recital 30 of the GDPR), recital 64 discourages "retain[ing] personal data for the sole purpose of being able to react to potential requests".
Your mention that you are not collecting any personal data suggests that the protections enacted in GDPR are not at stake. If anything, logging the IPs contributes to leaving traces and tends to trigger the undesired effects as outlined in recital 30: the possibility "to create profiles of the natural persons and identify them".
Additionally, it is not necessarily true that an IP can be mapped to a person (or this depends on the type of online service). Many transactions of data packets in Internet occur without human intervention. Even if an IP can be mapped to a person, it could be in the user's professional/official/non-personal capacity rather than the personal one. The GDPR only seeks to protect the latter.