java-8apache2ubuntu-16.04nio2

Java Apache2 Log File Permission Denied


I'm trying to read the apache2 custom log files in the /var/log/apache2/my_site/access.log in a Java program. But i get a permission denied Excpetion.

The code is working on the Winows OS, i can read the log file, but in Ubuntu, i cannot access the apache2 log files in the JVM. This is the output

output

The permissions snapshot

enter image description here

So how can i adjust the file permissions that i can read the file and Apache 2 still can write to it?


Solution

  • Fixed by changing the folder of the log file outside the /var/log/apache2 folder. Apache2 and JVM can both access the file in RW mode.