logrotate compresses old log files, which is kind to your disk and annoying when the error you are after happened four days ago. Plain grep on a .gz file searches the compressed bytes, so the line you want never shows up.
zgrep comes with gzip and decompresses on the fly. It passes your options straight on to grep, and uncompressed files work as well, so one command covers the current log and all the old ones:
zgrep -i 'out of memory' /var/log/syslog*
That searches syslog, syslog.1 and every syslog.N.gz in one go. Add -c to get a count per file, which shows quickly on which day a problem started, or -h to leave out the file names.
zgrep has two limits. It cannot walk folders: its man page lists -r, -R, --include and --exclude as unsupported, so hand it the files yourself or let find pick them:
find /var/log -name '*.gz' -mtime -7 -exec zgrep -l 'segfault' {} +
That lists the compressed logs from the last week that mention a segfault. And it is built around gzip. For .xz logs the xz package has xzgrep, and zstd ships zstdgrep, which work the same way.
Further reading: zgrep(1) manual page, xzgrep(1) manual page