Cpanel error log

This article will teach you how to view your cPanel logs on your server.

cPanel comes with an error log section that allows you to view errors generated by your website. In this article, we will review how to view your error logs for both Apache and PHP from within cPanel. For more information, we have a full guide that also lists the locations of cPanel logs for access, Apache, email, error, ftp, mysql, and WHM.

  • What is the Error Log?
  • cPanel Error Log
  • How do I Read Error Log?
  • PHP Error Logging
Don’t have time to read the article? Watch our walk-through video.

What is the Error Log?

cPanel states, “This function will display the last 300 errors for your site. This can be very useful for finding broken links or problems with missing files. Checking this log frequently can help keep your site running smoothly.” What this means is when your site is visited by someone, the server receives a request from that visitors browser and location to your server. When the visitor hits a section of your website and they cause an error, the error log will log the date, time, IP , page the error occurred and so forth. These errors could be caused for a number of reasons. Below are a few reasons why errors would be thrown.

  • Page Alias Changed (SEF URL’s or Permalinks changed)
  • File was deleted or renamed
  • SpamBots trying to manipulate a url
  • Missing error pages or robots.txt
  • Menu links changed with out redirecting
  • Old URLS cached in search engines

There are many reasons your site could have errors. Its a good idea to check you error log frequently to fix web crawler problems that effect your search engine ranking and website functionality.

You can find your cPanel Error log by following the steps below.

  1. Login into your cPanel.
  2. Go to Metrics > Errors.
    cPanel error log icon
  3. Your error log will display in the box. cPanel will display the last 300 errors through the Error Log interface.
    cPanel error log sample

How do I read error log?

Below is an excerpt of a typical error in the cPanel Error log. There are many different error types you may receive. The below is an error on a missing file with a brief description.

Date and Time logged Type Visitor IP Address [Fri May 17 21:07:47 2013] [error] [client 122.96.59.103] Location of the Error File does not exist: /home/userna5/public_html/400.shtml, Domain Referrer referer: https://example.com/?m=200911

PHP Error Logging

By default, InMotion disabled PHP error logging on all servers. In order to troubleshoot your PHP code, PHP errors can be enabled to display and log errors using your local php.ini file or ini_set() in a specific PHP file. Then, any errors will be logged within a file labeled error_log in the same directory that the script produced the error. For more information, see our full guide on How to Display and log errors for PHP.

php Error Log Sample

Within the file, you will see each error that was logged on a separate line. First, it will list the date and time that the error was produced, then the actual error. Reviewing this periodically will help you provide the best experience possible for your visitors to ensure that they are not seeing repeat errors on your website.

PHP error logs are one of the most useful tools for diagnosing web hosting issues. It’s often difficult to find the cause of unexpected behavior in WordPress® and other PHP applications. PHP error logs, including WordPress logs,  can help you to spot problems and identify the offending plugin, theme, or custom code. 

In this article, we describe what PHP error logs are and why they’re useful, before explaining how to use cPanel & WHM to activate and configure both WordPress logs and the PHP runtime’s logging functionality.  

What is a PHP Error Log?

A PHP error log lists warnings and error messages, which are generated by the language runtime and saved to a file. WordPress is written in PHP, so it handles WordPress’s error messages and logging. 

Errors occur for lots of reasons. A line of code might have a typo in it, or the code might be fine, but something unexpected happens when it’s executed. Either way, the developers want to let you know, so they write code to log a message to a file. Error logs are a time-ordered list of these messages. 

Error logs are incredibly useful for figuring out why WordPress isn’t behaving as you think it should. If it’s consuming excessive server resources, a plugin is broken, or pages don’t load, the logs can tell you why. If you’re in a “White Screen of Death” situation where WordPress isn’t working at all, the logs might be the only way to see what’s going on under the hood.

Before you can troubleshoot with logs, you’ll need to tell WordPress or PHP to start logging. Error logs are off by default because logging consumes server resources.  They can also be a security risk if the wrong person sees them; logs sometimes have clues about potential vulnerabilities. 

We’re going to look at two approaches to configuring error logging in cPanel. They are:

  • Activating WordPress logging via the wp-config file. 
  • Activating PHP logging via the php.ini file. 

Both can be done quickly in cPanel & WHM. 

WordPress Error Logs with Wpconfig.php

The wp-config.php file contains WordPress’s configuration, and, with a couple of lines of code, you can turn on debugging mode and tell WordPress to write errors to a log. 

First, fire up cPanel’s File Manager, which you will find in the main page’s Files section. 

Your WordPress site is probably in the root or a subdirectory of public_html, although it might be somewhere else if your server has a non-standard configuration.

Click on the directory containing the site and find the wp-config.php file in the right-hand pane. Select it and click Edit in the menu bar. 

The file opens in cPanel’s text editor. Scroll down to the line that reads: 

/* That's all, stop editing! Happy blogging. */

Add the following code above that line and then click Save:

define( 'WP_DEBUG', true );
	define( 'WP_DEBUG_LOG', true );
	define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

We’re telling WordPress to turn on debugging mode and output error messages to the log file. We also tell it not to display errors in the interface, because that’s not a good look for a production website. 

WordPress will now write error messages to a file called error.log in the wp-content directory, which is in the root directory of your WordPress site. 

You can use the cPanel File Manager and text editor to open this file and see the error messages. The most recent messages are at the bottom of the file. They tell you the type of error and which code triggered it, allowing you to track down the plugin or theme file responsible. 

When you have diagnosed the problem, be sure to delete the logging code you added to the configuration file. The error file will keep growing and will eventually consume a large chunk of your disk allocation. 

How To Log PHP Errors Beyond WordPress

The method outlined above is great if you want to manage logging through WordPress, but what if you want to log errors for other content management systems and applications? 

To achieve widespread logging, you can add code to the php.ini file, which you can edit in cPanel’s MultiPHP INI Editor. You will only be able to edit this file if your web hosting environment allows it. 

Select the Editor tab and then a location in the dropdown menu. cPanel displays the existing configuration file, which may be blank. 

Add the following to the text entry field and click Save

log_errors = true
error_log = /home/user1/logs/error.log
display_startup_errors = false
display_errors = false
html_errors = false
error_reporting = E_ALL
log_errors_max_len = 0

These directives tell the runtime to log errors to the file designated with error_log, which you should change to your preferred location. We’ve turned off startup errors because they are rarely relevant for debugging misbehaving applications. We also instruct PHP not to display errors in web pages because we don’t want users to see them. 

Click Save, and PHP will start to log errors to the file you chose. You can access the log via the cPanel File Manager or by logging in with SSH. 

The php.ini directives we used are suitable for most web servers, but you can use many other directives to configure PHP. To learn more, take a look at the list of php.ini directives in the language’s documentation and our MultiPHP INI Editor documentation.

Once you have used the logs to figure out your issue’s source, remove the code you just added or change the log_errors value to false to deactivate logging.

Efficient Issue Resolution with PHP Error Logs and cPanel

Logs are an enormously useful tool for diagnosing and fixing unexpected behavior in WordPress sites and other web applications. With cPanel & WHM, it’s straightforward to activate and deactivate logging, reducing the time you spend hunting down elusive issues. 

As always, if you have any feedback or comments, please let us know. We are here to help in the best ways we can. You’ll find us on Discord, the cPanel forums, and Reddit.

cPanel has a vast amount of log files which can be reviewed when errors happen. Whether you’re seeing an Internal Server Error or a blank page. The cPanel log files will contain all of the information needed to diagnose and fix most issues. Here we are going to point out the cPanel log files mostly used and show you how to find information in these files. If you need log files related to email like send and receive information and Exim then you can check our Exim Log Files post which details all the information related to Exim.

Apache Log File

Apache will log any information related to your HTTP service so. You can search the file for specific information using the grep command below. Replace [USERNAME] with the cPanel user having issues to bring back a full list of log incidents for that user.

grep [USERNAME] /var/log/apache2/error_log

cPanel Access Log

The cPanel Access Log will keep a record of login and logout actions by cPanel users and WHM users. The file writes a new entry on each line in the format [IP] [DATE&TIME] [ACTION]. The Access log file can be found at;

/usr/local/cpanel/logs/access_log.

cPanel Error Log

Although the cPanel Error Log contains errors related to cPanel. If a user removed a MySQL database. This will be written to the cPanel Error Log. Other errors related to cPanel and WHM will be found in this file located at

/usr/local/cpanel/logs/error_log

cPanel Backup Log Files

cPanel will write any information related to backups to the cpbackup directory. The cpbackup log will only record information about backups. The directory will contain a list of recent backup jobs in the format 1519178402.log, 151987402.log. Each file is a separate backup process. The files are located at

/usr/local/cpanel/logs/cpbackup    

These are a few of the most common logs for cPanel and WHM. You can find a full list of log files in the cPanel documentation. Find out how to Search Linux log files.

How was this article?

You might also like

More from cPanel

Help fixing Error: last request failed: [AUTH] Authentication failed.

The Error: last request failed: [AUTH] Authentication failed error can be caused by a range of things. It could be …

How To Install Ioncube V11 In cPanel

How To Install Ioncube V11 In cPanel
Ioncube have released V11 of the Ioncube Loaders. Ioncube protects PHP code from theft …

cPanel Backups Per Account or Entire MySQL Directory?

cPanel Backups Per Account or Entire MySQL Directory?
The integrated cPanel backups system allows you to take a backup of each …

Editor Picks

Knowledgebase Home / How to Check Your Website’s Error Log in cPanel

// View Comments //

If your website is not functioning or there is an error the first thing to check is the error log. cPanel comes with a built-in error log section that allows you to see the errors. In this document, we will discuss how to diagnose your website so you correct the problems.

You can check your website for errors in the cPanel interface or from the cPanel File Manager. First we will discuss how to check the errors via the cPanel interface.

Viewing Errors in the cPanel Interface

From the cPanel interface you can only see the last 300 errors your website logged. This can be very useful for finding broken links (404 errors) etc.

  1. Log in to your cPanel account and navigate to Metrics > Errors.

    The cPanel Metrics Page.

    The cPanel Metrics Page.

  2. You will see a box here and it will have the last 300 errors of the website.

The most recent error logs from your website.

The most recent error logs from your website.

Viewing Errors in the cPanel File Manager

You can see all the errors your website is generating using the cPanel File Manager tool.

  1. Login to cPanel.
  2. Click on the File Manager under Files.
  3. Move to the public_html folder, then select and open the error_log file.

    The Apache error_log in cPanel File Manager.

    The Apache error_log in cPanel File Manager.

How to Read The Errors

Basically an error log has five fields: date and time when it happened, type of error, the visitors IP, the location of where the error is occurring and the domain it is referring to. For most cases these details are sufficient to determine what is wrong and when it first started occurring.

Date and Time logged          Type      Visitor IP Address
[Fri Jan 17 21:07:47 2019]   [error]   [client 192.168.0.32] 

Location of the Error
File does not exist: /home/userna5/public_html/400.shtml, 

Domain Referrer
referer: http://example.com/?m=200911

Conclusion

Great work! Now you know how to check and review your website’s error logs in case there’s an issue.


If you have any web hosting questions please feel free to reach out to us.
We’re happy to help.


Our Guiding Principles

  • Provide consistent, stable, and reliable web hosting services.
  • Ensure rapid ticket response and quick resolutions to issues.
  • Never saturate or over-provision servers to ensure stability and speed for our customers.
  • Use only high-quality enterprise-class hardware to ensure minimal downtime from hardware failures.
  • Provide clear pricing with no hidden fees or gotchas.

I can guarantee you, I am not the only person who has been driven to madness at least once in a frustrating search for a log file. It seems like it should be the easiest thing to find in the whole system.

A definitive guide on where the PHP error log is stored would be a complicated bit of work. The official PHP manual does not even try to address the whole topic, because there are dependencies on systems outside PHP, such as the operating system (Linux vs. Windows, which distribution of Linux), including settings within Windows and Linux that affect the name and location of the PHP error log.

Until someone takes the time to write a complete, cross-system guide, the best you are going to get is general directions where you can inquire. Every PHP developer has had to endure agony in this pursuit, with one exception. If you work in one place and the information is provided when you first need it, then you have the information need forever, that is, until you find yourself in a new working environment. There are such fortunate people.

If the information is not given to you on a silver platter, so to speak, you have some hunting to do. The hunt is not the longest you will face in your career, but it is not the simplest either.

As is evident from the many answers already posted, a smart place to begin is the output of phpinfo(). To view it, create a PHP file containing this:

<?php
    phpinfo();

Either browse to that file or run it from the command line. If you do both, you likely will find the error_log is in different places, depending on command line vs. web server use of PHP. That is because the PHP interpreter that runs on a web server is not the same PHP interpreter that runs from the command line, even when the command line is on the same machine as the web server. The answers already posted in here mostly are making an unstated assumption that PHP is running as part of a web server.

Sample output from phpinfo() via web server and web browser

The default for error_log is no value

Default error_log in php running as an Apache mod.

Whatever the value is, it comes from the php.ini files used to configure PHP. There can be many php.ini files. Finding your way among them is confusing at first, but you do not need to deal with this to find your PHP log.

If the output from phpinfo() shows a full path to a file, that is where the log is. You are lucky.

The trick is there usually is not a full path indicated in phpinfo(). When there is not a full path, the location depends on:

  1. Whether error_log is no value. If it is, the log file location will depend on the operating system and the mode PHP is running. If PHP is running as an Apache module, on Linux the log often is in /var/log/apache2/error.log. Another likely spot is in a logs directory in your account home directory, ~/logs/error.log.

  2. If there is a file name without a path, the location depends on whether the file name has the value syslog. If it syslog, then the PHP error log is injected into the syslog for the server, which varies by Linux distribution. A common location is /var/log/syslog, but it can be anywhere. Even the name of the syslog varies by distribution.

  3. If the name without a path is not syslog, a frequent home for the file is is the document root of the website (a.k.a., website home directory, not to be confused with the home directory for your account).

This cheat sheet has been helpful in some situations, but I regret to have to admit it is not nearly universal. You have my condolences.

Enter image description here

Previously, we wrote this comprehensive blog post, with all the possible cPanel log files and the log locations. But there was not much information on how to use those log files. So I am redoing the post to have that necessary information as my readers asked.

The post will turn into a cPanel logs cheat sheet over time, helping our users find anything within CPanel log files. You better bookmark it 🙂

While working with cPanel logs, there are two fundamental questions.

  1. How to search
  2. Where are the logs located

We will address all three one by one.

How to search cPanel log files?

This is the primary concern of a part for novice cPanel admins i “How to search cPanel logs efficiently”. So here is a short lesson on that too.

Searching cPanel logs files are the same as searching any text file within Linux. You will be searching a lot of files for specific keywords or phrases. In cPanel shared hosting servers, these phrases are usually “domain names”, email addresses, and cPanel user names.

cPanel Log file can grow very large and are usually filled with a great deal of information that we do not need in day-to-day troubleshooting and management tasks. Due to the size of log files going through a file one line at a time is way out of the question. And Opening the file in any text editor like nano or vi is also of not much help as large files get too much slow, and it will be very time-consuming and tedious to do that this way.
As a cPanel server admin, you need to able to pinpoint warnings and errors, and the best tool to do that is “grep”
grep command is a versatile option to search cPanel log files. the syntax to use grep is

grep [options] [pattern] [file]

example:

grep 'keyword' /path/to/file.log

The most important is [keyword] here; it is what you want to search. If you want to search logs of a domain “my-examp.com” in apache logs, then it will be

grep 'my-example.com' /usr/local/apache/logs/error_log

Since Linux and its commands and everything within is case sensitive, you may miss cPanel log file searches because of it. To take care of this problem, you need to search log files as case insensitive. We do it with -i option

grep -i 'my-example.com' /usr/local/apache/logs/error_log

The output would show many many lines if my-example.com were a problem creating one. And in that case, it all just scrolls past the terminal screen until it reaches the end. And then you have to scroll up to read all that. Here we can use the command “less”.
So final command to search cPanel log files that you will be using all the time will become

grep -i 'my-example.com' /usr/local/apache/logs/error_log | less

One more thing that you will sometimes need within cPanel log file is context. It is to see what happened before this error and what after. For that, you may use some grep option that we will address in the next update. Or if you can buy cPanel administration services here.

Where are the cPanel logs?

This is what this article initially was about initially. We have described with each log file what information that log file holds. Different applications might have more than one log file, each containing a different type of information. Usually, there are usage logs, and there are error logs. For example, apache has a separate file to log access activity and another for apache error logs.
cPanel logs are most activity that happens on a server to log files so you can go back and check log records for issues, instead of having to be on the server at the time of them occurring.

cPanel Email logs

Exim logs:

  • Exim mail delivery and receipt logs: /var/log/exim_mainlog
  • Messages rejected based on polices and access control lists (ACLS): /var/log/exim_rejectlog
  • Fatal & Unexpected error log: /var/log/exim_paniclog
  • Mailque for incoming messages: /var/spool/exim/input/

Courier or Dovecot IMAP:

  • IMAP, POP login attempts, fatal errors and spam scoring: /var/log/maillog

Mailman:

  • Mailman mailing list logs: /usr/local/cpanel/3rdparty/mailmain/logs

Email clients: 

  • Horde email client logs:/var/cpanel/horde/log/
  • RoundCube email client logs:/var/cpanel/roundcube/log/
  • Logs related to squirrel Mail interface (was used in older cpanel versions): /var/cpanel/squirrelmail/

cPanel MariaDB/ MySQL logs

The file name is always with server hostname on the following location

  • MySQL error logs file location: /var/lib/mysql/{SERVER_NAME}.err
  • MySQL slow query log (slow queries logging can be enabled in my.cnf): /var/log/slowqueries
    We have a detailed post about identifying MySQL Slow Queries

cPanel Apache Logs

  • Apache Access Logs file location: /usr/local/apache/logs/access_log
  • Apache Error logs file location: /usr/local/apache/logs/error_log
    contains all Web server and CGI application error log
  • Apache restarts logs done through cPanel and WHM: /usr/local/cpanel/logs/safeapcherestart_log
  • Apache domain access  logs path: /usr/local/apache/domlogs/{DOMAIN}
    {Domain} will replace domain name i.e.,exmaple.com
  • Apache SUEXEC Logs: /usr/local/apache/logs/suexec_log
  • suPHP audit log: /usr/local/apache/logs/suphp_log
  • Modsecurity audit logs: /usr/local/apache/logs/modsec_audit.log
  • Modsecurity debug logs:/usr/local/apache/logs/modsec_debug_log

Cpanel logs

  • cPanel Installation Logs: /var/log/cpanel-install-thread0.log
  • cPanel Access Log:/usr/local/cpanel/logs/access_log
  • cPanel Error Log: /usr/local/cpanel/logs/error_log
  • cPanel License Log: /usr/local/cpanel/logs/license_log
  • cPHulkd logs:/usr/local/cpanel/logs/cphulkd.log
  • Stats Execution Logs: /usr/local/cpanel/logs/stats_log
  • cPanel Backup Logs: /usr/local/cpanel/logs/cpbackup/*.log
  • cPanel Backup transport to remote locations: /usr/local/cpanel/logs/cpbackup_transporter.log
  • Account transfers and misc. logs: /var/cpanel/logs
  • Auditing log (account creations, deletions, etc): /var/cpanel/accounting.log
  • Cpanel dnsadmin dns clustering daemon: /usr/local/cpanel/logs/dnsadmin_log
  • Cpanel taskqueue processing daemon: /usr/local/cpanel/logs/queueprocd.log
  • DBmapping logs: /usr/local/cpanel/logs/setupdbmap_log
    Logs about integrated applications, transfers from non-cPanel servers in relation to removing the restraint of MySQL database, usernames having to be prefixed by the cPanel account username
  • cPanel Panic logs: /usr/local/cpanel/logs/panic_log
  • Per account bandwidth history (Cached):/var/cpanel/bandwidth.cache/{USERNAME}
  • Per account bandwidth history: /var/cpanel/bandwidth/{USERNAME}
  • Tailwatch driver tailwatchd log: /usr/local/cpanel/logs/tailwatch_log
  • Update analysis reporting log: /usr/local/cpanel/logs/updated_analysis/{TIMESTAMP}.log
  • Update (UPCP) log: /var/cpanel/updatelogs/updated.{TIMESTAMP}.log
  • WebDisk (CPDAVD) logs: /usr/local/cpanel/logs/cpdavd_error_log

Other services

  • BIND (named) Log: /var/log/messages
  • ChkServd (cPanel Monitoring Daemon) Logs: /var/log/chkservd.log
  • SSH Logs: /var/log/secure
  • Pure-FTP:  /usr/local/apache/domlogs/ftpxferlog
  • Processing of log splitting: /usr/local/cpanel/logs/splitlogs_log
  • EasyApache build logs: /usr/local/cpanel/logs/easy/apache/
  • Locale database modifications log:/usr/local/cpanel/logs/build_locale_database_log
  • Login errors (CPSRVD) log: /usr/local/cpanel/logs/login_log
  • Cron job logs are common to all Linux servers: /var/log/cron
  • NGINX access log location: /var/log/nginx/access.log
  • NGINX error logs location: /var/log/nginx/error.log
  • tomcat error logs: /usr/local/jakarta/tomcat/logs/catalina.err tomcat connections: /usr/local/jakarta/tomcat/logs/catalina.out

Понравилась статья? Поделить с друзьями:
  • Could not save file maya как исправить
  • Could not reserve enough space for 2097152kb object heap как исправить
  • C14fe14 ошибка lexus
  • C10d018 ошибка вольво фмх
  • C10d018 ошибка вольво fmx