On a default Ubuntu installation, the Apache configuration file, /etc/apache2/apache2.conf contains the following line to ensure that log files are written by default.
ErrorLog ${APACHE_LOG_DIR}/error.log
The APACHE_LOG_DIR environment variable is set when the Apache service startup script run the shell commands in /etc/apache2/envvars, which include this variable assignment:
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
Unless you’re running multiple instances of Apache, SUFFIX will be an empty string so the log file directory is, by default, configured to be/var/log/apache2.