The default json-file driver keeps every log line forever unless you set limits. The local driver rotates and compresses out of the box, and docker logs keeps working.
docker run -d --log-driver local --name web nginx:alpine
docker inspect --format '{{.HostConfig.LogConfig.Type}}' web
According to the docs it keeps 100 MB per container by default, as five files of 20 MB, and stores them in a compact compressed format. You can change that with --log-opt max-size and max-file like with json-file.
To make it the default for every new container, set it in /etc/docker/daemon.json and restart Docker:
{
"log-driver": "local"
}
Existing containers keep the driver they were created with, so recreate them to switch. I would check the current default with docker info --format '{{.LoggingDriver}}'.
The files are in an internal format. Tools that read json-file logs straight from /var/lib/docker/containers, such as some log shippers and Promtail setups, will not understand them. If you collect logs that way, stay on json-file and give it size limits instead.
Further reading: Local file logging driver, Configure logging drivers