Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Så här ställer du in error loggar för WordPress i WP-Config

Vi anser att inställningar av loggar för fel är avgörande för din effektiva felsökning och underhåll av WordPress webbplatser.

Filen wp-config.php styr inställningarna för din WordPress webbplats och kan även användas för att aktivera loggning av fel. Den här funktionen hjälper dig att identifiera och lösa problem på ett effektivare sätt.

I den här artikeln kommer vi att visa hur du ställer in loggar för fel i WordPress med hjälp av filen wp-config.php. Genom att följa dessa instruktioner kan du effektivisera din felsökningsprocess och se till att din webbplats fungerar smidigt.

How to Set Up WordPress Error Logs in WP-Config

Varför konfigurera WordPress error loggar med WP-Config?

Filen wp-config.php är en viktig konfigurationsfil för WordPress. Den innehåller settings som talar om för din website hur den ska anslutas till din WordPress-databas, vilket prefix för database table som ska användas och nycklar för autentisering som gör din website säkrare.

Förutom standardinställningar för WordPress kan wp-config-filen också användas för att aktivera felsökningsläget för WordPress och spara WordPress error loggar.

Detta hjälper dig att hitta WordPress error genom att identifiera de tillägg eller skript som orsakar dem. Du kan sedan gå vidare och hitta en fix för dessa WordPress error.

Med detta sagt, låt oss ta en titt på hur du aktiverar och ställer in WordPress error loggar genom att editera wp-config filen.

Konfigurera error loggar för WordPress i WP-Config File

Först måste du editera din wp-config.php-fil. Om du inte har gjort det tidigare kan du läsa vår guide om hur du redigerar wp-config-filen i WordPress.

Du kan komma åt filen genom att ansluta till din website med hjälp av en FTP-klient eller den app för filhantering som tillhandahålls av din hosting provider.

Edit Your Website's wp-config.php File

Filen wp-config.php hittar du i root directory på din website.

Note: Edit WordPress core-filer kan vara farliga och förstöra din site om du gör ett litet error. Därför rekommenderar vi att endast avancerade användare gör detta.

Aktivera debug-läge

Därefter måste du öppna filen i en textredigerare och leta efter raden där det står ”That’s all, stop editing! Trevligt bloggande.

Strax före denna rad måste du add to följande kod:

define( 'WP_DEBUG', true );

Det är möjligt att den här koden redan finns i din wp-config.php-fil och är inställd på ”false”. I så fall behöver du bara ändra den till ”true”.

Denna rad aktiverar läget WordPress debug. Detta innebär att WordPress error och varningar kommer att visas i ditt admin area samt på front page på din website.

Därefter måste du aktivera error log så att felmeddelandena sparas i en fil.

Aktivera error loggning

Om du vill att error ska loggas måste du också add to följande kod i din wp-config.php file precis under WP_DEBUG-raden.

define( 'WP_DEBUG_LOG', true );

Glöm inte att save dina ändringar och uploada din wp-config.php-fil tillbaka till din website.

Grattis, du har aktiverat WordPress error logging. Nu ska vi ta en titt på hur du använder loggen för att hitta och fixa error vid troubleshoot.

Reviewer dina error loggar för WordPress

Först måste du besöka din WordPress site och komma åt de pages som resulterade i error eller varningar. Därefter måste du ansluta till din website med hjälp av en FTP-klient eller filhanteringsapp i din cPanel på ditt WordPress webbhotell.

När du är ansluten går du till mappen /wp-content/. Inuti den hittar du en fil som heter debug.log.

Download, View, or Edit the debug.log File

You can download, view, or edit this file.

Den kommer att innehålla alla WordPress error, varningar och notices som loggades.

Debug.log Contains Error Messages and Time Stamps

Expertguider för felsökning och debug errors i WordPress

Nu när du vet hur du ställer in WordPress error loggar, kanske du gillar att se några andra guider relaterade till logging, felsökning och debug errors i WordPress.

Vi hoppas att den här artikeln hjälpte dig att lära dig hur du ställer in WordPress error loggar i wp-config-filen. Du kanske också vill se vår guide om hur man skapar en gratis email address för företag och vårt expertval av de bästa e-postmarknadsföringstjänsterna för småföretag.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Avslöjande: Vårt innehåll stöds av våra läsare. Det innebär att om du klickar på några av våra länkar, kan vi tjäna en provision. Se hur WPBeginner finansieras, varför det är viktigt, och hur du kan stödja oss. Här är vår editoriala process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Den ultimata WordPress-verktygslådan

Få GRATIS tillgång till vår verktygslåda - en samling WordPress-relaterade produkter och resurser som varje professionell användare bör ha!

Reader Interactions

17 kommentarerLämna ett svar

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Jiří Vaněk says

    From a security point of view, is it good to have debug mode and debug log permanently on, or is it a better practice to turn it on only when a problem occurs?

      • Jiří Vaněk says

        Thanks for the reply, I usually used to leave it on for longer periods of time and then I learned that it’s not a good practice, so I wanted to check with the pros. Thank you for your time and new information.

  3. mohadese esmaeeli says

    Hello and respect;
    As an additional note, I would like to inform users that the error log file becomes heavy and bulky over time. It is advisable to delete it. Each time an error occurs, this file will be recreated. Visit the WordPress installation path and check the permissions of the error_log file. If the file is unnecessary, delete it. This file contains errors that have occurred on the WordPress site.

    • WPBeginner Support says

      It would depend on how often the site has an error but it would be a good idea to delete the file every so often.

      Administratör

  4. Eddy says

    Hi, quick question, one of my client’s sites has this text file error.log generated/updated under the public_html folder, yet, WP_DEBUG is set to false in wp-config, does anyone know what’s generating the error log in that file?

  5. hassu says

    My own plugin is broken, and this method does not help, the log file is empty and stays empty whatever trick i try.

  6. Zippp says

    Oh, Gosh
    If you are saying how to turn the logging on then why don’t you say how to add there any data?

    • Erick Racancoj says

      I thought the same :)

      Here is a line of code you can use once WP_DEBUG_LOG is activated:

      error_log( ’Hello World!’ );

      • Frank Spade says

        Your test code can only work, when you use aposthrophs instead of accents! ;-)

        error_log(’Hello World!’);

Lämna ett svar

Tack för att du väljer att lämna en kommentar. Tänk på att alla kommentarer modereras enligt våra policy för kommentarer, och din e-postadress kommer INTE att publiceras. Vänligen använd INTE nyckelord i namnfältet. Låt oss ha en personlig och meningsfull konversation.