Apache Access and Error Log File Location in Ubuntu

In my forum one of user has recently posted their query regarding Apache log files and their location. First of all let’s understand what is log file and why it is important.

What’s the use of log files

Log files are used to record URL request, user activity, ip address, errors and HTTP status code for each request.
For example-
Let’s say some user is browsing https://webrewrite.com/category/php/ this page. Every time user access this page, Apache writes a log entry in access log of following things. Url requested, time of request, HTTP status code, ip address of user etc.

If you are using log in your application, then definitely it’s a best practice to log exceptions and error, which occur while running an application. These logs are helpful for debugging and improving your application.

How to Install Apache,PHP,MySql on Ubuntu

There are two types of log files used by apache.

1. Access log – All incoming requests with their HTTP status codes are log into this file.

2. Error log – All errors occured during serving requests are logged into this file. Error might be memory exhaust, file not found (404) etc.

Where Apache Logs File is Stored in Ubuntu

In Ubuntu by default Apache log file is stored in

To check last 5 access and error log.

tail command is used to output the last part of files. tail -5 is used to output last five lines.

Top Ten Most Used Linux Terminal Commands

To check first five access and error log

head command is used to output the first part of files. Similarly head -5 is used to output first five lines.

Tagged , , , . Bookmark the permalink.

About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.