The failing line found in a wall of logs: a ChatGPT + Cursor stack

The struggle: You have a stack trace and thousands of log lines, and you cannot tell where the failure starts or which file to open.

What you end up with: The first real error in the logs, the file behind it, a tested fix and a regression test.

ChatGPT reads the log file and finds the first failure and the pattern around it. Cursor then plans in Plan Mode, finds the code, and fixes it in Agent while you read every change and run the tests.

Tools: ChatGPT, Cursor. Level: Free to start. Time: 45 min.

Use it if

  • You have a log file or stack trace and no idea where to start
  • The error repeats thousands of times
  • You can reproduce the problem locally

Skip it if

  • The logs contain data you cannot remove
  • You cannot test a fix locally

The method

  1. Clean the log before sharing (ChatGPT: Chat)

    Open a copy of the log and delete tokens, keys, emails, names, IP addresses and customer ids, using the checklist below. Keep timestamps, levels and message text. Have a second person skim it.

    Prompt to copy:

    I need to share a log with an AI. Without me pasting any of it, list the kinds of personal data and secrets that commonly appear in application logs (emails, names, tokens, API keys, session ids, IP addresses, customer ids, connection strings) and the search patterns I can use to find and remove them. Then give me a short checklist to confirm the file is clean.

    You get: A log with nothing private in it.

    Tip: If you cannot strip it, do not upload it. Use the stack trace only.

  2. Find the first failure (ChatGPT: Data analysis)

    Upload the cleaned file to a ChatGPT chat and ask it to analyse it with data analysis, grouping errors and finding the earliest one.

    Prompt to copy:

    Analyse this log file. 1) Group errors by message pattern with counts. 2) Find the earliest error and the lines just before it. 3) Say which errors look like consequences of others. 4) Quote the stack trace of the earliest one. State what you cannot tell from the log. Do not guess a fix yet.

    You get: A table of error types with counts and the first occurrence.

    Tip: The loudest error is often a symptom. The earliest one is usually the cause.

  3. Plan the investigation (Cursor: Plan Mode)

    In Cursor open the project, press Shift+Tab to switch to Plan Mode and paste the earliest error with its stack trace. Ask it to find the code and propose a fix plan.

    Prompt to copy:

    Here is the earliest error and stack trace: [paste]. Find the code path that produces it, name the files and the likely cause, and explain what other evidence would confirm it. Propose a minimal fix and a regression test. If you cannot find the code, say so.

    You get: A plan naming the files and the cause, with questions answered.

    Tip: Plan Mode asks clarifying questions. Tell it how to reproduce the error.

  4. Fix it and add a test (Cursor: Agent)

    Switch to Agent and build the plan. Let it write the fix and the test, then run the test yourself.

    Prompt to copy:

    Implement the fix from the plan and add one regression test that fails without the fix. Show the diff and the exact command to run the test. Make no unrelated changes.

    You get: A small diff with a test that failed before the fix and passes after it.

    Tip: Revert and refine the plan if the result is off, rather than patching it with more prompts.

  5. Read the diff, then check the logs again (Cursor: Agent)

    Read every changed line yourself, run the test suite, and reproduce the original problem to see the error is gone.

    Prompt to copy:

    List the places in the code with the same pattern as the bug we fixed and say which could fail the same way. Do not edit anything.

    You get: A fix you understand and a clean reproduction.

    Tip: Look for the same pattern in other places in the code.

Where this goes wrong

  • Logs often hold tokens and personal data. Strip them first, and do not upload what you cannot strip.
  • A plausible fix can hide the cause. Reproduce the problem before and after.
  • Free plans limit uploads and agent requests, so analyse a slice of the log.
  • Review the diff before you commit and never deploy untested.

Sources

More like this

Updated . Written with AI help and checked by an independent review step, as described in our editorial standards.