Ich versuche, die grundlegende Debug-Ausgabe mit WordPress für ein Plugin zu aktivieren, das ich entwickle. Ich habe es bisher geschafft, einige zu bekommen, konnte sie aber nicht umleiten wp-content/debug.log
. Ich bin ungefähr gefolgt die Anleitung von Douglas Neiner. Folgendes habe ich getan:
Ich habe dieses Code-Snippet am Ende von hinzugefügt wp-config.php
:
@ini_set ('display_errors', 0);
define ('WP_DEBUG', true);
define ('WP_DEBUG_DISPLAY', false);
define ('WP_DEBUG_LOG', true);
habe ich manuell erstellt debug.log
Datei und stellte sicher, dass sie zugänglich ist www-data
user (Ich führe WordPress lokal auf Ubuntu 12.04 aus):
septi@norbert:~$ sudo su www-data -c 'ls -l /usr/share/wordpress/wp-content/debug.log'
-rw-rw-r-- 1 root www-data 0 Dec 9 22:12 /usr/share/wordpress/wp-content/debug.log
septi@norbert:~$ sudo su www-data -c 'ls -l /srv/www/localhost/wp-content/debug.log'
-rw-rw-r-- 1 root www-data 0 Dec 9 22:12 /srv/www/localhost/wp-content/debug.log
septi@norbert:~$ sudo su www-data -c 'echo i can write >> /usr/share/wordpress/wp-content/debug.log'
septi@norbert:~$
Ein paar vermeintliche Debug-Ausgabeanweisungen innerhalb des Plugin-Aktivierungs-Hooks sowie den absichtlichen Fehler hinzugefügt:
include ('i fail wp');
register_activation_hook (__FILE__, 'hello_world_activate');
function hello_world_activate()
{
error_log ('I love debug output when it works!');
}
Was ich erwarte, ist eine Fehlermeldung über die fehlende Include-Datei in debug.log
zusammen mit dem “Ich liebe Debug-Ausgabe, wenn es funktioniert!” Nachricht, und nichts auf der Seite. Was ich bekomme, ist die fehlende Include-Datei in der Seitennachricht und nichts drin debug.log
. Die Debug-Ausgabenachricht geht jedoch nicht vollständig verloren. Ich fand es in der /var/log/apache2/error.log
:
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning: include(i fail wp): failed to open stream: No such file or directory in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning: include(): Failed opening 'i fail wp' for inclusion (include_path=".:/usr/share/php:/usr/share/pear") in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] I love debug output when it works!, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning: include(i fail wp): failed to open stream: No such file or directory in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning: include(): Failed opening 'i fail wp' for inclusion (include_path=".:/usr/share/php:/usr/share/pear") in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
Ich vermute, dass die error_log()
Die Funktion ist nicht die richtige, um sie für die Ausgabe zu verwenden debug.log
, aber ich habe den richtigen Weg nicht gefunden. Oh, natürlich könnte ich den Dateipfad einfach fest codieren und daran anhängen, aber, weißt du …
selbes Problem hier. Alles ist eingeschaltet, keine Fehler werden angezeigt
– weh
31. Oktober 2013 um 13:56 Uhr