技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
sap-log-reference【数据与研究】Find and read the right log or trace for any SAP component or database — instance work-directory traces (dev_disp, dev_w*, dev_ms, dev_rd, dev_icm), ABAP logs (SM21, ST22, SM50, SLG1), standalone components (Web Dispatcher, SAProuter, Cloud Connector, Host Agent, IGS) and each database's own logs (HANA trace dir, Oracle alert log, db2diag, ASE errorl…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Different layer → different location. This is the locator: symptom → which log → where it lives → how to read it. It complements sap-health-triage (which extracts logs via SAPControl) and sap-housekeeping (which cleans them up).
Guardrail note: reading is non-destructive — but confirm the SID/host before reading another system's logs, and remember many SAPControl read methods are protected (
service/protectedwebmethods— see health-triage §7). Raising trace levels (§ references) does change system behaviour/space — lower them again after diagnosis.
OS shell (UNIX — Linux/AIX):
tail -f <file> # follow live
less +G <file> # open at the end
grep -niE "ERROR|ORA-|\*\*\* ERROR|abort" <file> # hunt for errors
OS shell (Windows):
Get-Content <file> -Tail 100 -Wait # follow live
Select-String -Path <file> -Pattern "ERROR|abort"
Remotely / no shell — via SAPControl (cross-ref health-triage §2):
sapcontrol -nr <nr> -function ListDeveloperTraces # list the instance's dev_* files
sapcontrol -nr <nr> -function ReadDeveloperTrace dev_w0 0 # read one (size 0 = whole file)
sapcontrol -nr <nr> -function ReadLogFile <path> '' # any instance log file
sapcontrol -nr <nr> -function ABAPReadSyslog # SM21 system log
Work directory — /usr/sap/<SID>/<INST><nr>/work/ (Windows …\work\). The per-process traces:
| File | Component | Read when |
|---|---|---|
dev_disp | Dispatcher | instance won't start; overall instance issues |
dev_w0…dev_w<n> | Work processes | short dumps, DB connect errors, WP hangs |
dev_ms | Message Server (ASCS/SCS) | logon/load-balancing, instance registration |
dev_rd | Gateway | RFC/registered-program failures |
dev_icm | ICM (Internet Communication Manager) | HTTP/HTTPS, Fiori, web errors |
dev_rfc*, dev_rfc.trc | RFC client/server calls | RFC connection failures |
dev_enq*, enserver/enq* logs | Enqueue Server | lock / enqueue problems |
dev_sapstartsrv, sapstartsrv.log | sapstartsrv control service | SAPControl can't reach the instance |
stderr0/1/2…, available.log, sapstart.log | start-service | startup failures |
ABAP application logs (via SAP GUI / SAPControl):
| Where | Content | Shell equivalent |
|---|---|---|
| SM21 | system log (syslog) | sapcontrol … ABAPReadSyslog |
| ST22 | ABAP short dumps (runtime errors) | (dump text) |
| SM50 / SM66 | work-process overview + traces | sapcontrol … ABAPGetWPTable |
| SLG1 | application log (BAL) | — |
| ST11 | error-log files / developer traces | the dev_* files above |
| SM13 | update-request errors | dev_w* (update WP) |
| SMGW | gateway monitor + logging | dev_rd |
| RSAU_CONFIG / RSAU_READ_LOG / RSAU_ADMIN | Security Audit Log (SAL) — config / read / admin. Current as of SAP_BASIS 7.50 SP03; SM19/SM20/SM18 are legacy (SM19 may be display-only) | files per DIR_AUDIT/FN_AUDIT (…/<INST>/log/*.AUD) or the database [G6] |
| Symptom | Look here first |
|---|---|
| Instance won't start | dev_disp → stderr* → sapstart.log; then sappfpar check (health-triage) |
| "Database not available" / connect fails | dev_w0 (WP that connects) + the DB's own log (§5) |
| RFC / registered program fails | dev_rd (gateway) + dev_rfc*; SMGW |
| HTTP / Fiori / web error | dev_icm; ICM trace (raise via icm/trace_level) |
| Logon load balancing / message server | dev_ms; SMMS |
| Enqueue / lock issues | dev_enq* / enserver; SM12 |
| Random short dumps | ST22 + the referenced dev_w<n> |
| Slow / performance | ST03, ST04 (DB), the DB's expensive-statement log (§5) |
| Web Dispatcher / SAProuter / Cloud Connector | that component's own log (§4) |
Each ships its own trace, separate from any SAP instance — full map in references/app-and-component-logs.md:
| Component | Primary log | Notes |
|---|---|---|
| SAP Web Dispatcher | dev_webdisp, dev_webdisp_log in the Web Disp dir | ICM-based; raise via icm/trace_level [G3] |
| SAProuter | -T <tracefile> (level-2 trace) / -L <logfile> | enable per SAP KBA 3570238 [G5] |
| SAP Cloud Connector | ljs_trace.log (+ scc_*), rotates 20×50 MB | in the SCC install log/ dir [G4] |
| SAP Host Agent | dev_saphostexec, host-agent logs under /usr/sap/hostctrl/work | control-layer issues |
| IGS (graphics) | dev_igs* | chart/graphics rendering |
DB engines log outside the SAP work directory, each in its own place and format. Full per-DB map + readers in references/db-logs.md:
DB (dbms_type) | Primary log | Read with |
|---|---|---|
HANA (hdb) | /usr/sap/<SID>/HDB<nr>/<host>/trace/ — indexserver_*.trc, nameserver_*.trc, *_alert_*.trc | pager / HANA cockpit / M_MERGED_TRACES [G2] |
Oracle (ora) | ADR …/diag/rdbms/<db>/<SID>/trace/alert_<SID>.log; listener.log | adrci / pager |
ASE (syb) | $SYBASE/$SYBASE_ASE/install/<SERVER>.log (errorlog); <SERVER>_BS.log (Backup Server) | pager |
Db2 (db6) | db2diag.log in DIAGPATH (db2 get dbm cfg) | db2diag -H 1d |
MaxDB (ada) | KnlMsg / knldiag, dbm.prt in the run directory | Database Studio / pager |
SQL Server (mss) | …\MSSQL\Log\ERRORLOG; SQL Agent SQLAGENT.OUT; Windows Event Log | SSMS Log Viewer / xp_readerrorlog |
Cross-ref sap-db-command-reference for how to start/stop/connect each of these.
sap-nw-java-pi — AS Java traces in context: defaultTrace.trc, std_server<n>.out, dev_jcontrol, and the NWA Log Viewer/Configuration route.Every command executed must be traceable to one of exactly three things:
If a command is backed by none of those, do not run it — say what backing is missing and stop. "It's probably fine", "this is standard", and "I recall the syntax" are not backing. When the backing is a source, name it (page or Note number) alongside the command; when it is the user, quote the instruction.
If executing would require assuming anything the user did not state, you are obliged to confirm first. Never fill a gap with a plausible default. Common gaps that force a stop:
A wrong assumption here is not a typo — it is the difference between reading a log and stopping production.
Asking the user for something the system can answer is a failure. Before you raise a question, ask the user to go and look, or request Computer Use / GUI access, you must first try to determine it programmatically. Only what genuinely cannot be derived — intent, authorization, a business decision, a value that exists only in the user's head — is a legitimate question.
| Determine programmatically (do NOT ask) | Ask the user (cannot be derived) |
|---|---|
Which DB — echo $dbms_type, profile dbms/type | Which client to act on |
SIDs / instances / hosts / ports — sapcontrol … GetSystemInstanceList, ls /usr/sap | Whether this system is in scope / approved |
Is it up, is the DB up — GetProcessList, R3trans -d | PRD change approval, downtime window |
Kernel / release / patch — disp+work -version, saphostexec -version | The intended recovery point or retention policy |
Which clients exist — table T000 | Which of those clients is meant |
Free space, log locations, parameter values — df -h, sappfpar, profile | Business impact / urgency |
Order, always: verify programmatically → ask only what remains → never assume.
Work down this ladder. Take the highest rung that does the job — and within that rung, the lowest privilege that suffices. Never skip a rung because you assume it is unavailable (see the burden of proof below).
| # | Path | Privilege | Notes |
|---|---|---|---|
| 1 | REST / OData — GET first | Narrowest. Scoped service user | Read-only by construction when you stay on GET. $metadata gives you the contract |
| 2 | SOAP / web service | Scoped service user | Typed contract via ?wsdl. Client-cert auth where offered — no password in a script |
| 3 | RFC / BAPI (creds exec, JCo, pyrfc) | RFC user with S_RFC | For ABAP writes, prefer this over 1–2: BAPIs have real commit/rollback semantics and land in SM19/SM20 |
| 4 | OS shell as the correct user → DB utility | ⚠️ Escalates — see below | The chain matters more than the rung |
| 5 | Browser automation (headless or in-app) | Interactive user | Session-based UIs only. Fragile across releases |
| 6 | Computer Use / screen driving | Interactive user | Last resort. Not repeatable, not diffable, breaks on any UI change |
⚠️ Rung 4 is a chain, and each link widens the blast radius
ssh <host> ← host access → su - <sid>adm ← SAP admin: can stop/start the system → su - ora<sid> / syb<sid> ← DB owner: can drop data → sudo / root ← everything → hdbsql | isql | dbmcli | sqlplus | db2 ← the actual commandStop at the least-privileged user that can run the command. Most read-only checks need only
<sid>adm; DB utilities usually need the DB owner; root is almost never the right answer andsaproot.shis the rare legitimate exception. Say which user you used and why.
Two axes, and they do not agree
The ladder ranks by automation quality — repeatable, reviewable, loggable, diffable. Privilege runs on a different axis and is worst in the middle: rung 4 (OS/root) can destroy a system, while rung 6 (Computer Use) is merely an interactive user clicking. So Computer Use ranks last for reproducibility, not because it is the most dangerous.
The practical rule: prefer the highest rung, but never escalate privilege to climb it. A read-only OData call beats an RFC that needs a write-capable user; an
<sid>admshell beats a root shell. If climbing a rung requires more privilege than the task needs, stay where you are and say so.
🛑 You must demonstrate the absence of a programmatic path, not assume it
"There is no API for this" is a finding that requires evidence, not a default. Before dropping to rung 5 or 6, actually probe:
- HTTP status codes tell you the access mode.
401→ Basic auth works, scriptable.302regardless of credentials → session UI, browser needed.404→ not deployed.503→ deployed but stopped.- Look for a contract: append
?wsdl,$metadata,/api,?sap-client=and see what answers.- Ask the platform what it exposes:
sapcontrol -function J2EEGetApplicationAliasList,hdbcons help,btp --help,xs help,<tool> -h.- A Swing or WebDynpro UI being un-automatable does not mean the objects are. The editor and the API are different doors — check for the second before declaring the first is the only one.
Programmatic execution is repeatable, reviewable, loggable and diffable; screen-driving is none of those. When you do drop to a lower rung, say which rung you are on and what you probed to rule out the higher ones — so the user can correct you if they know of a path you missed.
Work that produces evidence (logs, traces, command output, screenshots, reports) has two reasonable endings. Ask which the user wants rather than guessing:
Don't dump large output into the conversation unasked, and don't silently discard evidence either — for troubleshooting and any change with a rollback, (a) is usually the right default to offer.
Identify the right OS user before running anything, and switch with a login shell. Wrong-user
execution is a top cause of SAP failures, and the damage outlives the command: files created by root
under /usr/sap, /sapmnt or a DB directory break every later start by the real owner. A login shell
also matters because each user carries the environment the tools need (SAPSYSTEMNAME, ORACLE_HOME/
ORACLE_SID, SYBASE, DB2INSTANCE, library paths) — without it, commands fail or act on the wrong system.
| What you're operating | UNIX user | Windows |
|---|---|---|
SAP instances — sapcontrol, startsap/stopsap, tp, R3trans, disp+work, sappfpar, cleanipc | <sid>adm (lower-case SAP SID) | <SID>adm; services run as SAPService<SID> |
SAP HANA — HDB, hdbsql, hdbnsutil | <sid>adm of the HANA SID (e.g. h10adm — may differ from the SAP SID) | n/a (HANA server is Linux-only) |
Oracle — sqlplus, lsnrctl, BR*Tools | ora<dbsid> (BR*Tools also runs as <sid>adm; generic installs may use oracle) | <SID>adm; DB runs as a service |
SAP ASE — isql, startserver, Backup Server | syb<dbsid> | syb<dbsid> / SAPService<SID> |
IBM Db2 — db2start/db2stop, db2 CLP | db2<dbsid> (the instance owner = DB2INSTANCE) | same; Db2 runs as a service |
SAP MaxDB / liveCache — dbmcli, x_server | sdb (software owner, group sdba) + a DBM operator at DB level | install/service account |
MS SQL Server — sqlcmd, service control | n/a (Windows-only for SAP) | <SID>adm / the SQL Server service account |
SAP Host Agent — saphostexec, saphostctrl | root | Administrator / SAPHostExec service |
Rules
su - <user> (the - is what loads the environment) or sudo -iu <user>.
Windows: use the correct account, or an elevated shell only where documented.root only where the procedure explicitly says so — e.g. saproot.sh after a kernel extract, SAP Host
Agent install/upgrade. Never as a shortcut around a permission error; that is how root-owned files get
created and break the system later.whoami / id, plus the env actually being set (echo $SAPSYSTEMNAME,
echo $ORACLE_SID, echo $DB2INSTANCE, echo $SYBASE).<sid>adm:"), and if the required user is not
available, say so and stop — do not substitute another user.SAP Notes supersede this file. Landscapes differ by release, patch level, DB and OS, and SAP changes procedures via Notes/KBAs between doc revisions.
If the SAP Notes MCP is configured, use it before acting on anything version-specific — especially any destructive step, or when a command here doesn't behave as documented:
search the topic (e.g. the component + symptom, or a Note number cited below).fetch the promising Note IDs for the current text, validity (affected releases/components),
prerequisites and side effects.attachments array. SAP routinely puts the actual deliverable in an attachment rather
than the Note body — sizing guides, SQL script collections, configuration PDFs, spreadsheets. A Note
whose text says "see the attached document" is not fully read until you have it.Downloading an attachment: fetch returns attachments[].url and attachments[].filename;
fetch_attachment retrieves the bytes. Pass the URL verbatim — the URLs are opaque and cannot be
constructed. If your MCP build predates that tool, open the URL in a signed-in browser instead and say the
file was fetched manually.
⚠️ Two ways a hand-rolled fetch goes wrong — both verified. 1. Trusting the status code. An unauthenticated request returns HTTP 200 with a small HTML login stub, not an error. Check the content type and magic bytes, or you save a JavaScript redirect page under a
…/services/attachment.htm?iv_key=…&iv_guid=…— so the URL basename isattachment.htmeven when the payload is a 24-page PDF. Take the name fromattachments[].filenameor the response'sContent-Dispositionheader, never from the URL path.
No MCP available? Look the Note up on me.sap.com/notes/<id> and say the check was skipped rather than
assuming this file is current.
/usr/sap/<SID>/HDB<nr>/<host>/trace/ (indexserver/nameserver/alert;
MDC SYSTEMDB + tenant subdirs) — SAP HANA Administration Guide / Troubleshooting & Performance Analysis.ljs_trace.log, rotation) — SAP BTP Connectivity / Cloud Connector
documentation (help.sap.com).RSAU_CONFIG/RSAU_READ_LOG/RSAU_ADMIN as of SAP_BASIS 7.50 SP03; DIR_AUDIT/FN_AUDIT; SAL can
be stored in the database (Note 3667538). https://me.sap.com/notes/2191612Complete inventory of every log/trace source, by layer: references/complete-log-inventory.md.
To confirm/deepen — check current SAP Notes with the SAP Notes MCP (search, then fetch the note ID): KBA 3570238 for the exact SAProuter
trace flags, and each DB's admin/troubleshooting guide for the current log paths on your release.