Two name tests joined with -o, then an action at the end. It looks right, but it only shows half the files.
find . -name '*.txt' -o -name '*.log' -print
This prints only the .log files. find joins tests with an implicit “and”, and “and” binds stronger than -o. So the command reads as: name is .txt, or (name is .log and print). The .txt files match the first part, but nothing tells find to print them. Without any action, find adds -print for the whole expression, which is why the version without -print does seem to work.
Group the alternatives with escaped parentheses:
find . \( -name '*.txt' -o -name '*.log' \) -print
The backslashes keep the shell from treating the parentheses as its own syntax, and there must be spaces around them.
This matters most with real actions. -name a -o -name b -delete deletes only the b files, and -exec behaves the same way. With -delete, getting the grouping wrong in the other direction can delete more than you wanted, so I’d always run the command with -print first and look at the list.
Further reading: find(1) manual page, GNU findutils manual