Go Back to Parent Doc

Managing Logs

Learn how to view, understand, and manage the logs generated by AI Content Writer.

Logs help you:

  • Monitor campaign activity
  • Diagnose errors and API issues
  • Understand what the plugin is doing behind the scenes
  • Keep your database clean and performant over time

Table of Contents

Overview

AI Content Writer records key actions and events in a dedicated Logs system, powered by a custom post type and admin list table (see includes/Admin/ListTables/LogsListTable.php and related classes).

These logs are especially useful when:

  • Setting up new campaigns
  • Debugging API issues (Gemini, ChatGPT, Pexels)
  • Tracking cron jobs and automation
  • Ensuring everything runs reliably at scale

Where Logs Come From

Logs are created by various parts of the plugin, for example:

  • Cron class (includes/Cron.php)
    • When generating titles, content, thumbnails, and publishing posts
    • When cleaning up old logs
  • Campaign processing functions (includes/functions.phpincludes/Campaigns/*.php)
    • When scraping sources
    • When generating AI content
    • When skipping duplicates or blocked items
  • Admin actions
    • When you manually trigger or change campaigns (depending on implementation)

Most log entries are created via a helper such as ai_content_writer()->create_log(...) with a message, status, and related campaign or post ID.

Accessing Logs in the Admin

Logs Menu

  1. Log in to your WordPress admin area
  2. Navigate to AI Content Writer → Logs

This opens a custom Logs screen powered by a list table class (AIContentWriter\Admin\ListTables\LogsListTable).

Logs Screen Layout

On the Logs page, you’ll typically see:

  • A table of log entries
  • Columns like DateMessageType/StatusCampaignPost ID, or similar (depending on implementation)
  • Bulk actions and filters at the top
  • Pagination controls at the bottom

The exact columns may vary slightly, but the goal is always to surface what happened, when, and for which campaign/post.

Understanding Log Entries

Each log entry usually includes:

  • Date/Time – When the action was logged
  • Message – Human-readable description of what happened
  • Type / Status – e.g., successerrorwarninginfo
  • Related Campaign – ID or title of the campaign involved (if any)
  • Related Post – ID or title of the post involved (if any)

Typical Success Messages

Examples of successful log messages you might see:

  • X posts titles and source links generated successfully.
  • Content generated successfully for post #123.
  • Thumbnail generated successfully for post #123.
  • Published 3 posts for campaign #456.
  • Old logs cleaned up successfully.

These indicate that the automation pipeline (titles → content → thumbnails → publish → cleanup) is running as expected.

Typical Error/Warning Messages

Examples of error or warning logs:

  • Failed to fetch RSS feed from URL: ...
  • Gemini API error: ...
  • OpenAI API error: ...
  • No results found for keywords: ...
  • Skipping duplicate post for title: ...

Use these entries as starting points when troubleshooting issues.

Filtering and Searching Logs

The Logs screen usually supports common list table interactions:

Screen Options

At the top-right of the screen, the Screen Options tab lets you:

  • Control how many logs to show per page
  • This value is stored via the set-screen-option filter (see Admin::screen_option() in includes/Admin/Admin.php)

Column Sorting

You can often click on certain column headers (like Date) to sort logs in ascending or descending order.

If a search box is present:

  • You can search by keywords in log messages
  • Useful for finding specific error types or campaign references

Filtering by Type or Campaign

Depending on the implementation of LogsListTable, you may see:

  • Dropdown filters by log type/status
  • Dropdown filters by campaign

Use these to narrow down the logs relevant to a specific problem.

Automatic Log Cleanup

To prevent your database from growing indefinitely, AI Content Writer includes an automatic log cleanup routine in includes/Cron.php.

Cleanup Cron Job

In the Cron class:

  • A scheduled hook (e.g., aicw_cleanup_logs) is registered in schedule_cron()
  • This hook is typically run daily
  • It calls a method like Cron::cleanup_logs()

What Cleanup Does

Cleanup may:

  • Delete logs older than a certain age (e.g., 30 or 90 days)
  • Limit logs to a maximum number of entries
  • Remove only certain log types (e.g., verbose info logs) while keeping error logs longer

The exact behavior depends on your current plugin version. You can inspect Cron::cleanup_logs() in includes/Cron.php for details.

Manual Cleanup (If Needed)

If you ever need to clean logs manually:

  1. Go to AI Content Writer → Logs
  2. Use bulk actions to delete selected logs (if enabled)
  3. Or run a one-off custom script/query (advanced, developer-only)

For safety, always back up your database before running manual queries.

Using Logs for Troubleshooting

When something isn’t working as expected, the Logs screen should be your first stop.

Common Scenarios

1. Campaign Not Generating Posts

Check logs for messages like:

  • No results found for keywords (Articles/Gemini/ChatGPT)
  • Failed to fetch RSS feed (RSS campaigns)
  • Campaign is paused or disabled
  • API error for Gemini or ChatGPT

Use this information to:

  • Adjust keywords or feed URLs
  • Fix API keys or quotas
  • Reactivate campaigns

2. Thumbnails Not Appearing

Look for messages related to thumbnails:

  • Thumbnail generated successfully for post #ID
  • Failed to download image from Pexels

Then:

  • Verify Pexels API keys
  • Check media upload permissions
  • Confirm your site can connect to external hosts

3. Cron Jobs Not Running

If you suspect cron isn’t firing:

  • Check logs for timestamps – are they being added regularly?
  • If no new logs appear over time, WP-Cron may be disabled or blocked
  • Consider setting up a real server cron job to hit wp-cron.php

4. API Quota or Error Issues

Logs often capture error messages returned by external APIs:

  • Gemini API error: quota exceeded or similar
  • OpenAI API error: invalid API key or insufficient_quota

Use these to:

  • Update or correct API keys
  • Upgrade your plan or reduce usage
  • Implement backoff or reduced posts per run

Best Practices

Regularly Review Logs

  • Set a schedule to check logs (e.g., weekly)
  • Focus on error and warning entries
  • Use logs to catch problems before they impact your site visitors

Keep Logs for a Reasonable Time

  • Rely on the built-in cleanup to avoid unbounded growth
  • If needed, adjust cleanup logic (developer-level customization)
  • Consider exporting important logs before they’re purged

Use Logs When Changing Settings

Whenever you:

  • Add new campaigns
  • Change API keys
  • Modify frequency or posts per run

…keep an eye on logs for a while to ensure the new configuration works as expected.

Avoid Debug Logging on Production (Unless Needed)

  • If you enable extra debugging or verbose logging for troubleshooting, remember to disable it afterward
  • Excessive logs can impact performance and disk usage

Examples

Example 1: Debugging RSS Feed Issues

Problem: RSS Feed campaign not generating posts.

Steps:

  1. Go to AI Content Writer → Logs
  2. Filter by the relevant campaign (if filter is available)
  3. Look for messages like:
    • Failed to fetch RSS feed from URL: ...
    • RSS feed returned empty or invalid XML
  4. Based on the message:
    • Test the feed URL directly in a browser
    • Replace the feed URL with a known good feed
    • Check if your server can access the host (no firewall/DNS issues)

Example 2: Diagnosing Gemini API Errors

Problem: Gemini campaign not generating content.

Steps:

  1. Check Logs for entries tagged with the Gemini campaign
  2. Look for messages like:
    • Gemini API error: invalid API key
    • Gemini API error: quota exceeded
  3. Actions:
    • Correct the API key in Settings → API Settings → Gemini
    • If quota exceeded, reduce posts per run, reduce active campaigns, or upgrade your plan

Example 3: Confirming Automation Runs

Scenario: You want to make sure cron jobs are running on schedule.

Steps:

  1. Review logs for messages such as:
    • X posts titles and source links generated successfully.
    • Content generated successfully for post #ID.
    • Thumbnail generated successfully for post #ID.
    • Published X posts for campaign #ID.
  2. Check timestamps:
    • Are they appearing roughly at your configured intervals (e.g., hourly)?
    • If not, investigate WP-Cron or server cron configuration.

Last Updated: November 28, 2025 | Plugin Version: 2.1.0

Shopping Cart
  • Your cart is empty.
Scroll to Top