Search code examples
kuberneteslogginggcloud

Kubernetes pods logs are not getting by kubectl logs command


I am using a WordPress site build with Kubernetes deployment. In the deployment I have only one container pod. Could you please clarify the possible reasons on the logs are not getting via kubectl logs command. I have tried docker logs on the container also, which is also showing the same output.

#~$ kubectl logs -f <pod_name> -n <namespace>
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using xx.xx.xx.xx. Set the 'ServerName' directive globally to suppress this message

This is the only content in logs even after accessing the domain.

# docker logs -f <k8s_container_name>
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using xx.xx.xx.xx. Set the 'ServerName' directive globally to suppress this message

Solution

  • kubectl logs show the default STDOUT and STDERR

    You need to write the file_put_contents('php://stderr', 'Your text goes to STDERR',FILE_APPEND);

    at least append in file and you read from there or else if you developing php WordPress you can push logs to external logging also.

    Read more at : https://www.php.net/manual/en/features.commandline.io-streams.php & https://docs.docker.com/config/containers/logging/