Long running shell script can utilize the following command to tag its log with its own PID:
logger -t "ident[$$]" -p user.notice "test"
As documented with logger(1) manual page, the logger does not tag the entry with its PID without -i flag, so the script may fabricate PID part of the entry. And this worked for years (until FreeBSD 12+) including matching resulted entries by ident in syslog.conf:
!ident *.* /var/log/ident.log
This was broken with FreeBSD 12+ due to incompatible libc changes: now PID of called process added forcibly despite of PID already added to the ident. Proposed change restores compatibility while keeping implicit addition of PID for processes that do not call openlog(3) with omitted LOG_PID and fabricated PID within the ident.