12

My error when writing a plugin for uploads

and yes, I can debug. But it just jumps directly from this line to destruct

enter image description here

the end of my wp-config.php EDIT:

// Enable WP_DEBUG mode
define('WP_DEBUG', true);

// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

(yes i did restart)

My webcontent folder

enter image description here

So now what?

How do I find out what is the problem?

EDIT it's not file permission as I can do error_log("errrorrrr ", 3 , "..../debug.log")

In my plugin I wrote the line

throw new \Exception("foo");

I want to get to see the error in my debug.log file

9
  • You have to create the debug.log file in wp-content/ for debug logging to work.
    – mike23
    Feb 10 '15 at 9:44
  • @mike23 no didn't help, I used as well error_log("errrorrrr ");
    – Toskan
    May 25 '15 at 20:26
  • Side note. Have you checked permissions. Permission to write to debug.log.
    – Omar Tariq
    May 25 '15 at 20:48
  • 1
    You said "the end of my wp-config.php"... Is it literally the end? Constants definition goes before the line require_once(ABSPATH . 'wp-settings.php'); or it does nothing...
    – gmazzap
    May 26 '15 at 1:55
  • 1
    Make sure you disk-space is not full May 26 '15 at 10:04
10
+50

Insert this into your wp-config.php

// Enable WP_DEBUG mode
define('WP_DEBUG', true);
// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);
// Disable display of errors and warnings 
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);

Before

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

2
  • the @ini_set('display_errors',0); isn't necessary. define('WP_DEBUG', true); // Enable Debug logging to the /wp-content/debug.log file define('WP_DEBUG_LOG', true); are essential. Also, be sure about chmod ing the folders correctly, e.g. wordpress needs to be able to have write access to that folder (for ubuntu chmod ug+rw -R /folder/to/wordpressinstall )
    – Toskan
    Nov 22 '15 at 17:42
  • A bunch of errors in the control panel wouldn't look good, that is why I added @ini_set('display_errors',0); Nov 23 '15 at 18:22
1

I had a similar issue when the permissions on the upload dir were not allowing the upload, try that first. Take a look at the codex Changing_File_Permissions for more info.

Alternatively, check that the uploads dir is owned by the same user (on the server) as Wordpress, it's also mentioned in the above link.

For how to... please find someone with more experience ;)

1
  • i can write to the debug.log file using a special command, see my edited question
    – Toskan
    May 27 '15 at 16:52
0

Toskan,

It seems like your wordpress file is not uploaded, so there may be a possibility for one or more issue, Please read out following and apply these solution one by one:

Large images require more memory to process. Are these images particularly large? If yes then try with small image.

Uploaded folder should have write permission, if not then please grant it.

Need to check uploaded directory structure having sub folder created with your current setting OR not, if not then try it manually may be this is again folder permission issue.

If above points is not your solution then please use wordpress plugin 'Debug My Plugin' with Debug Bar(https://wordpress.org/plugins/debug-my-plugin)

It adds a debug menu to the admin bar that shows query, cache and other helpful debugging information.

Also 'Query Monitor'(http://wordpress.org/plugins/query-monitor) is monitoring database queries, hooks, conditionals, HTTP requests, query vars, environment, redirects including automatic AJAX debugging and more.

I hope you find this detail helpful. If you have any query or suggestions to achieve the same result as above plugins does, do share with us.

Thanks!

1
  • I just want to use the wordpress debug.log file, I thought it's simple. Right?
    – Toskan
    May 27 '15 at 16:52
0

Another thing to check for is where the WP_CONTENT_DIR points as that is where the debug.log file will be put. This can be set in wp-config.php e.g. define('WP_CONTENT_DIR', '/var/www/sites/wordpress/wp-content');. Normally it shouldn't need to be set unless there's a non-standard setup. The value of WP_CONTENT_DIR may be checked as suggested in this question, or using the Wordfence plugin->Tools->Diagnostics->WordPress Settings.

0

In my case, I use XAMPP to host WordPress, the log will be in Apache's error.log instead even I have wp-config.php configured.

XAMPP Log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.