Understanding the Logical Capabilities of Large Language Models via Out-of-Context Representation Learning