Your yaml syntax isn’t quite correct. The documentation says it should be options not log-opt (https://docs.docker.com/compose/compose-file/#logging). Try this?
services:
service_name:
logging:
driver: "json-file"
options:
max-size: "50m"
You should define logging section in each one of your services not directly in root of docker-compose.