Debug settings

480 views
Skip to first unread message

Mike Little

unread,
Jun 15, 2011, 8:12:40 PM6/15/11
to Manchester WordPress User Group (MWUG)
I mentioned in this evening meeting about good debug settings for WordPress.

You may see a few resources that will tell you to add the WP_DEBUG setting to you wp-config.php page. But by itself that can be quite harmful as in many server configurations, your site will start showing PHP error and warning messages *on you site pages*. It will also log these errors to Apache's error log, which is not always the best place for them to go.

Here are the settings I use.
define('WP_DEBUG', true); // false
if (WP_DEBUG) {
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);
}

These few lines go into your wp-config.php and, as always with additions to this file, you should put them just above the line that says /* That's all, stop editing! Happy blogging. */

The next thing you will probably need to do is create a file called debug.log in you wp-content directory. Depending on your permissions, WordPress may be able to create it itself. If it cannot create the file yourself locally, you can add a line of text to it if your software has issues creating empty files, then upload it to your wp-content directory.

Next make sure the permissions on this file are correct. If it got created for you they will probably be correct, though you may have trouble deleting it via ftp. but if you manually created it, then you will probably want to set the permissions to 666 (not 666 is for files, 777 is for folders -- but only when you want any and everyone to be able to write to or  delere that file/folder.

Once you have done this, you should see the size of the file growing as you use your site. At any point you can download it to get a good look at it. With luck a clue to the problem you are having will be found in there. Most messages will tell you what the error or warning is, and list the file and line where the problem occurred.

Remember to turn debugging off when you have finished your investigation.

There are some further debug flags to help debugging JavaScript and CSS. See http://codex.wordpress.org/Editing_wp-config.php


Hope this helps,


Mike
--
Mike Little


Philip Norton

unread,
Jun 16, 2011, 4:02:57 AM6/16/11
to manchester-word...@googlegroups.com
Thanks Mike, that's really useful information! I see you are also mentioned by name on the wp-config page you sent over :)

Phil


--
See the group blog at http://mwug.info
 
You received this message because you are subscribed to the Google
Groups "Manchester WordPress User Group" group.
To post to this group, send email to
manchester-word...@googlegroups.com
To unsubscribe from this group, send email to
manchester-wordpress-...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/manchester-wordpress-user-group?hl=en?hl=en

Azizur Rahman

unread,
Jun 16, 2011, 10:26:12 AM6/16/11
to manchester-word...@googlegroups.com
The code presented here is ideal because it only create/update the log file when you have debug turned on, Where as the code on the codex page keeps writing to log regardless.
Reply all
Reply to author
Forward
0 new messages