Logs
Aidbox produces structured logs on every significant event to the internal stream which you may direct to different ways:
Logs exporting with OTEL spec
Aidbox supports the OpenTelemetry protocol and exports logs in Protobuf format to any consumer that supports this specification.
See also OpenTelemetry Logs
Logs API
You can get current logs through REST API by GET /_logs
- response will be Chunked Transfer Encoding stream of new line separated JSON objects:
GET /_logs
# resp
{"ev":"w/req","w_url":"/Patient","w":"w3","w_m":"get","tn":"edgeniquola","ts":"2019-04-18T13:35:43Z","w_addr":"83.243.75.14, 35.244.249.127","ctx":"d0625fcf-f1a7-4b78-bbdf-b4ec87b6fb57","w_qs":null}
{"d":3,"sql":"\nselect true from _box where id = 'self'\nand resource @>\njsonb_build_object(\n 'participant',\n jsonb_build_array(json_build_object('user', json_build_object('id', ?::text )))\n) ","db_prm":["github-32066"],"ts":"2019-04-18T13:35:43Z","w":"w3","ev":"db/q","tn":"edgeniquola","ctx":"d0625fcf-f1a7-4b78-bbdf-b4ec87b6fb57"}
{"d":8,"sql":"SELECT \"patient\".* FROM \"patient\" LIMIT ? OFFSET ?","db_prm":["100","0"],"ts":"2019-04-18T13:35:43Z","w":"w3","ev":"db/q","tn":"edgeniquola","ctx":"d0625fcf-f1a7-4b78-bbdf-b4ec87b6fb57"}
{"ev":"w/resp","ctx_end":true,"w_url":"/Patient","w":"w3","w_m":"get","tn":"edgeniquola","ts":"2019-04-18T13:35:43Z","d":15,"w_st":200,"ctx":"d0625fcf-f1a7-4b78-bbdf-b4ec87b6fb57"}
....
Logs in browser
You can open [aidbox-base]/_logs
in your browser, and Aidbox will produce logs in pretty format, similar to AIDBOX_STDOUT_PRETTY format for stdout. Appeared in v2210. Available formats: ui (default), json, event-stream. Use the following parameter to change the format [aidbox-base]/_logs?format=json
Configure logging
Stdout log
Aidbox sends logs into stdout if one of these env variables defined: AIDBOX_STDOUT_JSON
, AIDBOX_STDOUT_PRETTY
.
Both environment variables enable logging to stdout but the difference is log format.
Example of the log output when AIDBOX_STDOUT_JSON
enabled
AIDBOX_STDOUT_JSON
enabled{"sql":"SELECT 1","d":2,"ts":"2022-10-26T10:59:59.825Z","w":"main","ev":"db/q"}
Example of the log output when AIDBOX_STDOUT_PRETTY
enabled
AIDBOX_STDOUT_PRETTY
enabled11:01:12 main [1ms] SELECT 1
Log to file
If you prefer to write logs into the file system, in the .env file specify AIDBOX_LOGS
environment variable with a relative path to the desired location.
AIDBOX_LOGS=/logs/aidbox
Another option is to store logs in:
Last updated
Was this helpful?