Logging for better analysis¶
Patcherly analyzes the error text your connector sends from monitored log files. Message-only lines (no stack frames) often leave the AI without enough call-site context to propose a reliable patch. Thin file or site environment context can also reduce accuracy — see Context collection.
Patcherly does not inject tracing into your app (unlike APM SDKs). Standalone PHP, Python, and Node connectors run outside your process and only see what lands in watched logs.
Enable full exception stacks in your logger so the connector can forward them.
What a good log event looks like¶
Prefer one multi-line event that includes:
- The error message / exception type
- Stack frames with file paths and line numbers
- (Optional) a clear “thrown in” / closing locus for PHP
Path-only fatals (a path on the message line but no frames) are still ingestible when a path can be extracted, but analysis quality is usually weaker. Prefer a full stack when your framework can emit one.
PHP / WordPress¶
Bad (message only, or path on the fatal line with no frames):
[23-Oct-2026 14:02:11 UTC] PHP Fatal error: Uncaught Error: Tenant Context in /var/www/html/wp-content/themes/my-theme/inc/cart.php:142
Good (message + Stack trace: / #N frames and/or thrown in … on line N):
[23-Oct-2026 14:02:11 UTC] PHP Fatal error: Uncaught Error: Tenant Context in /var/www/html/wp-content/themes/my-theme/inc/cart.php:142
Stack trace:
#0 /var/www/html/wp-includes/template-loader.php(132): include()
#1 /var/www/html/wp-blog-header.php(19): require_once()
#2 /var/www/html/index.php(17): require()
thrown in /var/www/html/wp-content/themes/my-theme/inc/cart.php on line 142
Python¶
Bad (exception string only, no Traceback / File frames):
Good (Traceback header or orphan File "…", line N frames with paths):
ERROR app: Tenant Context
Traceback (most recent call last):
File "/app/views/checkout.py", line 88, in create_order
ctx = require_tenant(request)
File "/app/services/tenant.py", line 14, in require_tenant
raise ValueError("Tenant Context")
ValueError: Tenant Context
Node.js¶
Bad (message only, no at …(file:line:col) frames):
Good (error type/message plus stack frames with file paths and line:column):
TypeError: Tenant Context
at requireTenant (/app/services/tenant.js:14:11)
at createOrder (/app/routes/checkout.js:88:17)
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
Bare frames such as at /app/routes/checkout.js:88:17 are also useful when present.
WordPress¶
- In
wp-config.php, enable logging with display off in production:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
- Confirm
wp-content/debug.log(or your custom log path) is on the site’s Monitored Logs list. - Emergency Rescue can record a single-line fatal when PHP shuts down. That line often has a path but no stack frames. For better analysis, keep
debug.logmonitoring enabled so the fullerStack trace:block is ingested when WordPress writes it.
See also WordPress connector and Custom log paths.
PHP (including Laravel)¶
- Ensure
log_errorsis on and fatals reach the file Patcherly watches. - Laravel: prefer
report($e)/Log::error(..., ['exception' => $e])so Monolog includes the stack. Confirmstorage/logs/laravel.log(or your channel path) is monitored. - Avoid logging only
$e->getMessage()without the exception object.
Python¶
- Use
logger.exception("…")orlogger.error("…", exc_info=True)insideexceptblocks so the Traceback is written. - Framework defaults (Django / Flask / FastAPI) usually log stacks to stderr or a configured file — point Patcherly at that file under Monitored Logs.
- Avoid
logger.error(str(e))alone when you need a patchable analysis.
Node.js¶
- Log
err.stack(or a serializer that includesstack) to the watched file. - For Express-style handlers, log the full
Errorobject, not onlyerr.message. - Structured loggers (pino / winston): enable stack serializers for error objects.
Missing path vs missing stack¶
- Ignored — no source file path: the log had no extractable path, so Patcherly cannot back up or patch. Fix logging so paths appear (often by enabling stacks). See the tip on ignored errors in the dashboard.
- Not patchable after analysis: analysis finished without a draft patch. A missing stack is a common cause; thin FILE CONTEXT can also contribute (Context collection, Auto-analysis).
Related¶
- Context collection — FILE CONTEXT, plan depth, detection snapshots
- Understanding errors — detection and analysis overview
- Connectors overview — standalone agents and monitored logs
- Custom log paths