WPCode Logo

WPCode Documentation

Documentation, Reference Materials, and Tutorials for WPCode

Most Popular

Get free tips and resources right in your inbox, along with 500+ others

Follow Us

Using Snippet Error Logging

Would you like to see exactly what your code snippets are reporting, without opening a single file on your server?

In this guide, we’ll walk you through turning on WPCode’s snippet error logging and reading the results from your WordPress admin.

Before you get started, make sure WPCode is installed and activated on your WordPress site.

Turning On Error Logging

To get started, we’ll turn logging on so WPCode has somewhere to keep the record.

Error logging keeps a written record of everything your snippets report. It puts that record in your WordPress admin, instead of a file you need FTP to reach. The switch starts off, so nothing is recorded until you turn it on.

From your WordPress admin sidebar, go to Code Snippets » Settings. Then select the Error Handling tab.

The WPCode Settings screen with the Code Snippets menu shown in the sidebar and an arrow pointing at the Error Handling tab

The Error Handling tab holds every setting to do with snippet errors. The logging switch comes first. The email options follow underneath it.

The Error Handling tab showing the Error Logging toggle switched on above the Email Notifications heading

At the top of the tab, switch Error Logging on.

An arrow pointing at the Error Logging toggle, shown switched on, with its View Logs link beside the description

With this on, WPCode writes each entry to a log file in your uploads folder. The Logs tab reads those files back for you.

The description beside the switch carries a View Logs link that jumps straight to that tab. That saves a trip through the menu once entries start arriving.

Note: Logging starts when you save, so the logs cover what your snippets report from that point on.

At the bottom of the panel, click Save Changes.

An arrow pointing at the Save Changes button at the bottom of the Error Handling tab

Your error logging settings are now saved.

Sending Notifications to Your Inbox

Requirements: Email notifications are available in the paid versions of WPCode.

The logs wait for you to come and read them. WPCode can also come to you by emailing you the moment it writes an entry. The rest of the Error Handling tab covers that.

Under the Email Notifications heading, switch Error Notifications on.

An arrow pointing at the Error Notifications toggle, shown switched on, under the Email Notifications heading

Each email names the snippet involved and links to its edit screen, so you can go from the message to the code in one click.

In the Send To field, enter the addresses that will receive those emails.

An arrow pointing at the Send To field for error notifications, holding one email address

Your site’s admin email address is there to begin with. The field takes a comma-separated list, so both a developer and the site owner can get the same email. The emails go to whatever addresses the field holds when you save.

To see how one of these messages is laid out before you ever receive one, click Preview Email. It opens a sample in a new browser tab.

An arrow pointing at the Preview Email button below the Send To field

Deactivation Notifications covers the second message WPCode can send. To be told whenever WPCode takes a snippet out of service on its own, switch it on.

An arrow pointing at the Deactivation Notifications toggle, shown switched on, with its own Send To field below

It has its own Send To field and its own Preview Email button, so the two message types can go to different people. When you’ve set both the way you want them, click Save Changes.

The last Send To field and Preview Email button, with an arrow pointing at the Save Changes button below them

Your notification settings are now saved, and you’re ready to read what WPCode has recorded.

Viewing Your Error Logs

Everything WPCode records is readable from the admin, so you never need to download a file to see it.

From your WordPress admin sidebar, go to Code Snippets » Tools. Then select the Logs tab.

The WPCode Tools screen with the Code Snippets menu shown in the sidebar and an arrow pointing at the Logs tab

The tab opens on the first log it finds and shows its contents straight away.

Note: If you have only just switched logging on, the tab tells you no logs were found until your snippets report something.

The filename appears as the heading. Beside it, the Delete log button removes the file you’re looking at. We cover that in the Removing a Log section below.

The picker on the right lists every log WPCode holds. The panel underneath holds the entries themselves.

The Logs tab showing a log filename as the heading, a Delete log button, the log picker with a View button, and one entry in the panel below

WPCode starts a fresh log file for each day. The date is part of the filename, so the list doubles as a timeline.

Two kinds of file can appear in that list.

  • A name beginning with error holds everything reported that day.
  • A name beginning with snippet holds the entries for one snippet, and carries that snippet’s ID in the filename. This kind is useful when you want to follow a single snippet rather than the whole site.

To read a different day or a different snippet, choose its file from the picker. Then click View.

An arrow pointing at the log picker dropdown, with the View button beside it

The panel then holds the entries from the file you picked.

Reading a Log Entry

Every line follows the same shape: a full timestamp, then the message WPCode received. The timestamp tells you when the entry was written, down to the second. The message is the part that tells you what your code was doing.

Some messages name something specific, such as a function. That name is a shortcut back to the code, because the snippets list searches the code inside your snippets as well as their titles.

Searching Code Snippets for that name will turn up the snippet holding it.

For more on tracing a message back to the snippet that produced it, see our guide on debugging PHP errors in WPCode.

Removing a Log

Once you’ve finished with a log, clearing it out keeps the picker down to the days you care about.

With the log you want on screen, click Delete log beside its filename.

An arrow pointing at the Delete log button beside the log filename heading

Your browser asks you to confirm before anything is deleted. Once confirmed, WPCode removes that one file. The rest of your logs stay exactly as they were.

That’s it! You now have a written record of what your snippets report, a way to have it delivered to your inbox, and somewhere in the admin to read it. Next, our guide on PHP error handling and safe mode shows how WPCode keeps your admin reachable while you work through a log.

Frequently Asked Questions

Below, we’ve answered some of the most common questions about WPCode’s snippet error logging.

Where does WPCode keep the log files?

In a folder named wpcode-logs inside your WordPress uploads directory. WPCode creates that folder the first time it needs it. At the same time it adds an index.html and a .htaccess file, so the contents aren’t served to visitors.

Why are there two log files for the same day?

Because WPCode keeps a combined log alongside the per-snippet ones. The file whose name starts with error collects everything reported that day. A file whose name starts with snippet covers a single snippet, and carries that snippet’s ID in its name.

Does a log file keep growing?

No. Once a day’s file passes WPCode’s size limit, WPCode starts a new one. It keeps the earlier files beside it with a numbered suffix, up to ten of them.

Who can open the Logs tab?

The Logs tab checks the same permission WPCode uses for editing PHP snippets, so a user needs that permission to read a log. The Access Control tab shows which roles hold it, and lets you change them.

Are the notification emails sent on a schedule?

No. WPCode sends each one as it records the entry, so the email arrives at the same time as the log line.

What is in a notification email?

The subject line names your site and the ID of the snippet involved. The body gives you the snippet’s title as a link to its edit screen, the address the entry was recorded on when WPCode has one, and the full message.

Do I get both emails when a snippet is deactivated?

No. When WPCode has taken a snippet out of service, it sends the deactivation message for that event rather than the error message. Each type carries its own subject line, so the two are easy to tell apart in your inbox.

What does the Logs tab show before anything is recorded?

A short line telling you no logs were found, with a link back to the Error Handling tab so you can check the switch. Once a file exists but happens to be empty, the tab names the file and tells you the log is empty.

Still stuck? How can we help?

Last Updated on

Get Started Today & Add Your Own Snippets

Future-proof your website with WPCode Snippets and improve the way you manage code across all your websites.