--- title: Introduction project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/introduction/ updated: 2026-11-19T08:02:30.706Z --- # Introduction > What OpenLogger is, what it does and where to start. OpenLogger is a small log server for your other apps. Your apps send their logs to it with one HTTP request, and you read, filter and download them in one web interface. It suits apps that need a shared place for audit trails, errors and important events. OpenLogger is an official Total.js app under the MIT license. The code is on [GitHub](https://github.com/totaljs/openlogger). ## What you can do - Receive logs from any app that can send an HTTP request, with an **API token** per app. - Store for every log the app name, a type (`info`, `warning`, `error` or `success`), a message, the user, the URL, the IP address, the device and any extra data as JSON. - Browse all logs in a table, newest first, and filter and sort them by any column. - Open a log to see all its details, with the extra data formatted as JSON. - Remove single logs, clear all logs, and download the log file. - Read the logs from your own scripts with the admin API. ## How it fits together 1. You protect the admin interface with a primary access token. 2. You create an API token for each app, for example `Demo project`. 3. Your app sends `POST /` with the token and a JSON body such as `{"app":"Demo project","type":"error","message":"Report export failed"}`. 4. OpenLogger stores the log, and you see it in **Logs**. ## Where to go next - Install OpenLogger: [Install from source](../install-source/) or [Install with Docker](../install-docker/). - Protect the admin interface: [First start](../first-start/). - Connect your first app: [API tokens](../api-tokens/) and [Send a log](../../reference/send-log/). - Send the audit logs of a Total.js app: [Total.js audit logs](../../recipes/totaljs-audit/). --- title: Install from source project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/install-source/ updated: 2026-11-19T08:02:30.706Z --- # Install from source > Download OpenLogger, install it with npm and start it. OpenLogger is a Node.js app. You need [Node.js](https://nodejs.org) with npm and, to download the code, Git. ## Download and start **1.** Download the code: ```bash git clone https://github.com/totaljs/openlogger.git cd openlogger ``` **2.** Install the dependency (the Total.js framework): ```bash npm install ``` **3.** Start the app: ```bash npm start ``` OpenLogger listens on port `8000`. Open `http://127.0.0.1:8000/` in your browser: you land on the admin interface at `/setup/`. ## Use another port `npm start` runs `node index.js 8000`. To use another port, start the app with the port number: ```bash node index.js 8080 ``` ## Where your data goes OpenLogger keeps everything in the `databases` folder inside the app folder: the logs, the API tokens and the configuration. See [Back up your data](../backups/). ## Next step Before you do anything else, set a primary access token: [First start](../first-start/). --- title: Install with Docker project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/install-docker/ updated: 2026-11-19T08:02:30.326Z --- # Install with Docker > Build a Docker image from the repository and run OpenLogger with a volume for its data. The repository contains a `Dockerfile`. You build the image from the code and run it with a volume, so your logs and tokens survive a new container. ## Build the image **1.** Download the code: ```bash git clone https://github.com/totaljs/openlogger.git cd openlogger ``` **2.** Build the image: ```bash docker build -t openlogger . ``` ## Run the container ```bash docker run -d --name openlogger -p 8000:8000 \ -v openlogger-data:/www/.src/databases \ openlogger ``` Open `http://127.0.0.1:8000/` in your browser and continue with [First start](../first-start/). Inside the container, OpenLogger keeps its data in `/www/.src/databases`. The volume `openlogger-data` holds the logs, the API tokens and the configuration, so you can remove the container and start a new one without losing them. ## Update to a new version **1.** Download the new code with `git pull` and build the image again with `docker build -t openlogger .`. **2.** Remove the old container and start a new one with the same volume: ```bash docker rm -f openlogger docker run -d --name openlogger -p 8000:8000 \ -v openlogger-data:/www/.src/databases \ openlogger ``` ## Good to know - `docker run` without a volume keeps the data only in that container. Removing the container removes your logs and tokens. - Changes to tokens and the configuration are written to disk about 10 seconds after you save them. Wait a moment before you stop the container. --- title: First start project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/first-start/ updated: 2026-11-19T08:02:30.326Z --- # First start > Protect the admin interface with a primary access token and find your way around. On the first start, the admin interface at `/setup/` is open to anyone who can reach the server. Protect it right away with a **primary access token**. ![The start screen of OpenLogger with Logs, Tokens and Configuration](/files/JapX0J6AV61f.webp) ## Set the primary access token **1.** Open `http://127.0.0.1:8000/setup/` and click **Configuration**. **2.** Under **Security**, click **Generate** below **Primary access token**, or type your own token. **3.** Copy the token and keep it in a safe place, for example a password manager. **4.** Click **SUBMIT**. The message "The configuration has been saved successfully, but the app needs to be reloaded." appears. Click **OK**. The app reloads at `/setup/?token=YOUR_TOKEN`. From now on: - `/setup/` without the token answers `401 Unauthorized`. - You open the admin interface at `/setup/?token=YOUR_TOKEN`. - The home page `/` shows only the name of the app. If you lose the token, see [Access and tokens](../../faq/access/). ## Find your way around The icons on the left open the three parts of the app: | Icon | Opens | What you do there | |---|---|---| | Clock | **Logs** | [Browse](../logs/), [filter](../filter-logs/), [remove](../remove-logs/) and [download](../download-logs/) logs. | | Key | **Tokens** | [API tokens](../api-tokens/) for your apps. | | Cog | **Configuration** | [Name and primary access token](../configuration/). | The book icon opens the online documentation. --- title: API tokens project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/api-tokens/ updated: 2026-11-19T08:02:28.886Z --- # API tokens > Create a token for each app that sends logs, copy it, and change it. Your apps send logs with an **API token**. Give every app its own token, so you can change one without touching the others. ![The Tokens screen with the tokens Demo project and Demo shop](/files/JapX035wV61f.webp) ## Create a token **1.** Click the key icon on the left to open **Tokens**, then click **Create**. **2.** Enter a **Name**, for example `Demo shop`. **3.** **Access token** is already filled with a random value. Keep it, or enter your own (5 to 50 characters). **4.** Click **SUBMIT**. ![The Create token form with Name and Access token](/files/JapX045xV60f.webp) The option **Allow read list of profiles** has no effect in OpenLogger. You can leave it as it is. ## Copy the token for your app Click the cog of a token and choose **Copy URL address**. OpenLogger copies the address that your app sends logs to, with the token in it, for example `https://logs.example.com/?token=YOUR_TOKEN`. You can use this address as it is, or take the token from it and send it in the `x-token` header. See [REST API overview](../../reference/rest-api/). ## What a token can do A token can only send logs. It cannot read logs and gives no access to the admin interface. Use the primary access token to [read logs from a script](../../reference/read-logs/). ## Change or revoke a token **1.** Click the token card, or click its cog and choose **Edit**. The **Update token** form opens. **2.** Change **Access token** and click **SUBMIT**. The old value stops working at once, and the app gets `401 Unauthorized` until you give it the new value. Use this to revoke a token: give it a new random value that you do not hand out. ## Good to know - Keep tokens out of code that runs in the browser. Send logs from your server. - After six requests with a wrong token, OpenLogger blocks the address that sent them for up to 15 minutes, even with a valid token. See [Errors](../../reference/errors/). --- title: Browse logs project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/logs/ updated: 2026-11-19T08:02:31.630Z --- # Browse logs > Find your way around the Logs screen: the columns, the pages and the buttons. **Logs** shows every log that your apps sent, newest first. Click the clock icon on the left to open it. ![The Logs screen with logs from Demo project and Demo shop](/files/JapX0W6MV61f.webp) ## The columns | Column | What it shows | |---|---| | **App** | The app that sent the log, in a colour of its own. | | **Type** | `info`, `warning`, `error` or `success`. | | **Created** | When OpenLogger received the log. | | **Schema** | The part of the app the log belongs to, for example `Orders`. | | **User** | The name of the user. | | **Message** | The text of the log. | | **Device** | The device or browser of the user. | | **URL address** | The address the user was on. | | **IP address** | The IP address of the user. | What a column holds depends on what your app sends. See [Send a log](../../reference/send-log/). ## Pages The table shows 100 logs per page. Use the arrows at the bottom to move between pages. The number of logs is at the bottom right. ## The buttons | Button | What it does | |---|---| | **Refresh** | Loads the newest logs. | | **Download** | Downloads the log file. See [Download logs](../download-logs/). | | **Remove** | Removes the checked logs. See [Remove and clear logs](../remove-logs/). | | **Clear** | Removes all logs. | ## More - Find logs with the filter row: [Filter and sort logs](../filter-logs/). - Double-click a log to see all its details: [Log detail](../log-detail/). --- title: Filter and sort logs project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/filter-logs/ updated: 2026-11-19T08:02:29.975Z --- # Filter and sort logs > Narrow the Logs table down with the filter row and sort it by any column. The row below the column names holds a **Filter** field for each column. Use it to find the logs you need. ![The Logs table filtered by the type error](/files/JapX0F67V60f.webp) ## Filter **1.** Click the **Filter** field of a column, for example **Type**. **2.** Type a value, for example `error`, and press **Enter**. The table shows only the matching logs. The filter finds the text anywhere in the column and ignores upper and lower case, so `shop` finds `Demo shop`. You can fill in several filters at once; a log must match all of them. To remove a filter, click the **×** in the field. ## Sort Click a column name to sort by it. Click again to reverse the order. Without sorting, the newest logs come first. ## Show more columns The columns **User ID** and **Data** are hidden. To show one, click the columns button at the right end of the header row, check the column and click **Apply**. **Reset** brings back the default columns. ## Good to know - The filters search all logs, not only the current page. --- title: Log detail project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/log-detail/ updated: 2026-11-19T08:02:31.178Z --- # Log detail > Open a log to see all its fields and the extra data formatted as JSON. Double-click a log in **Logs** to open **Log detail**. It shows every field of the log, and the extra data that the app sent in `data`. ![The Log detail panel of an error log with the data report and timeout](/files/JapX0R6JV60f.webp) ## What you see - **Application**, **Type**, **Schema**, **User ID**, **User name**, **IP address**, **URL address**, **Device**, **Message** and **Created**. - Below the table, the `data` of the log, formatted as JSON. It appears only when the app sent data. Close the panel with the **×** at the top right. ## Get more out of the detail The detail is as useful as the data your app sends. Put whatever helps you understand the event in `data`, for example the order number or the settings of a failed report. See [Send a log](../../reference/send-log/). --- title: Remove and clear logs project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/remove-logs/ updated: 2026-11-19T08:02:31.630Z --- # Remove and clear logs > Remove selected logs or all logs from the database. Logs stay in OpenLogger until you remove them. You can remove some logs or clear them all. Removed logs cannot be restored, so [download](../download-logs/) them first if you need a copy. ## Remove selected logs **1.** In **Logs**, check the box at the start of each log you want to remove. The box in the header checks all logs on the page. **2.** Click **Remove**. It is active only when at least one log is checked. **3.** Confirm with **Remove**. **4.** Click **Refresh** to see the list without the removed logs. ## Clear all logs **1.** In **Logs**, click **Clear**. **2.** Confirm with **Clear**. **3.** Click **Refresh**. The screen shows "The logs doesn't contain any logs". Clear removes the logs of all apps. --- title: Download logs project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/download-logs/ updated: 2026-11-19T08:02:29.465Z --- # Download logs > Download the log file and read what is inside. **Download** in **Logs** saves the whole log database as the file `logs.nosql`. Use it to keep a copy before you clear logs, or to work with the logs in other tools. ## Download the file **1.** Open the admin interface with your primary access token, at `/setup/?token=YOUR_TOKEN`. **2.** Open **Logs** and click **Download**. The browser saves `logs.nosql`. ## What is inside The file is plain text with one log per line, as JSON: ```json {"type":"info","data":"{\"order\":1001,\"total\":49.9,\"currency\":\"EUR\"}","app":"Demo shop","url":"https://shop.example.com/checkout/","userid":"u100","username":"Jane Doe","schema":"Orders","reference":"1001","message":"Order 1001 created","ua":"Firefox 132 (macOS)","ip":"192.0.2.10","clientside":false,"date":"2026-11-19T07:48:59.085Z","id":"24nap001bg51d","dtcreated":"2026-11-19T07:48:59.085Z"} ``` The file holds every field your app sent, including `reference`, `clientside` and `date`, which the table does not show. A line that starts with `-` is a log that was removed. ## Download from a script See [Read logs with the admin API](../../reference/read-logs/). --- title: Configuration project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/configuration/ updated: 2026-11-19T08:02:29.465Z --- # Configuration > Change the name of the app and the primary access token. **Configuration** holds the name of your OpenLogger and the primary access token. Click the cog icon on the left to open it. ![The Configuration screen with Name, Primary access token and the OpenPlatform section](/files/JapX0A62V61f.webp) ## Name **Name** is shown in the browser tab and on the home page `/`. Change it to tell several installations apart, for example `Demo logs`, and click **SUBMIT**. ## Primary access token The **Primary access token** protects the admin interface and the admin API. See [First start](../first-start/). To change it: **1.** Click **Generate** or type a new token. **2.** Click **SUBMIT** and then **OK**. The app reloads with the new token in the address. The old token stops working at once. Update the scripts that [read logs](../../reference/read-logs/) with the primary access token. ## OpenPlatform The **OpenPlatform** section is for running OpenLogger inside Total.js OpenPlatform. Leave **Request token** and **Response token** empty otherwise: when they are filled in, the primary access token does not open the admin interface. If that happens, see [Access and tokens](../../faq/access/). --- title: Back up your data project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/backups/ updated: 2026-11-19T08:02:28.886Z --- # Back up your data > Which files hold your data, and how to back them up and restore them. OpenLogger keeps all its data in the `databases` folder inside the app folder. With Docker, it is the volume mounted on `/www/.src/databases`. See [Install with Docker](../install-docker/). ## The files | File | What it holds | |---|---| | `databases/logs.nosql` | All logs, one per line. | | `databases/memorize_data.json` | The API tokens and the configuration, including the primary access token. | ## Make a backup **1.** Stop OpenLogger. **2.** Copy the `databases` folder: ```bash cp -a databases databases-backup-$(date +%Y%m%d) ``` **3.** Start OpenLogger again. `memorize_data.json` contains all tokens in plain text. Store backups where only you can read them. ## Restore a backup Stop OpenLogger, replace the `databases` folder with the backup, and start OpenLogger again. ## Good to know - Changes to tokens and the configuration are written to `memorize_data.json` about 10 seconds after you save them. Wait a moment before you stop the app. - `logs.nosql` grows with every log. To keep it small, [download](../download-logs/) the logs you want to keep and [clear](../remove-logs/) the rest. --- title: Run in production project: OpenLogger version: 1.0 section: guides language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/guides/production/ updated: 2026-11-19T08:02:31.630Z --- # Run in production > Start OpenLogger in release mode and protect the server. `npm start` runs OpenLogger in debug mode, which is meant for development. On a server, start it in release mode. ## Start in release mode ```bash node index.js 8000 --release ``` To keep it running after you log out and after a restart of the server, start it with a process manager or a system service, for example systemd. The [Docker image](../install-docker/) runs in debug mode with `npm start`. ## Protect the server - Set a [primary access token](../first-start/) before the server is reachable from the internet. - OpenLogger listens on all network interfaces. Put it behind a reverse proxy such as Nginx with HTTPS, and let only the proxy reach the port of OpenLogger. Tokens travel in every request, so never use plain HTTP over the internet. - If only your own servers send logs, allow only their addresses at the firewall or in the proxy. - Give every app its own [API token](../api-tokens/). - Back up the `databases` folder. See [Back up your data](../backups/). --- title: REST API overview project: OpenLogger version: 1.0 section: reference language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/reference/rest-api/ updated: 2026-11-19T08:02:31.630Z --- # REST API overview > The endpoints your apps call, how to send the token and what comes back. Your apps talk to OpenLogger over HTTP. Every address starts with your OpenLogger address, for example `https://logs.example.com`. ## Endpoints | Method and path | Token | What it does | |---|---|---| | `POST /` | API token | [Send a log](../send-log/). | | `POST /api/` | Primary access token | [Read, remove and clear logs](../read-logs/). | | `GET /api/download/` | Primary access token | [Download the log file](../read-logs/). | ## Send the token Send the token in one of two ways: - in the `x-token` header: ```bash curl -H "x-token: YOUR_TOKEN" -H "content-type: application/json" \ -d '{"app":"Demo project","type":"info","message":"User signed in"}' \ https://logs.example.com/ ``` - or as the `token` query argument: ```bash curl -H "content-type: application/json" \ -d '{"app":"Demo project","type":"info","message":"User signed in"}' \ "https://logs.example.com/?token=YOUR_TOKEN" ``` The header keeps the token out of server logs, so prefer it when your app can set headers. ## Request formats `POST /` accepts JSON (`application/json`) and form data (`application/x-www-form-urlencoded`): ```bash curl -H "x-token: YOUR_TOKEN" \ -d "app=Demo project" -d "message=Nightly backup finished" \ https://logs.example.com/ ``` ## What comes back A stored log answers `200`: ```json {"success":true} ``` Errors come back as a JSON array or, for a wrong token, an HTML page. See [Errors](../errors/). --- title: Send a log project: OpenLogger version: 1.0 section: reference language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/reference/send-log/ updated: 2026-11-19T08:02:31.630Z --- # Send a log > POST / stores one log: the fields, their limits and an example. `POST /` stores one log. Send it with an [API token](../../guides/api-tokens/). ## Request ```bash curl -H "x-token: YOUR_TOKEN" -H "content-type: application/json" \ -d '{ "app": "Demo project", "type": "error", "schema": "Reports", "message": "Report export failed: timeout", "userid": "u101", "username": "John Smith", "url": "https://app.example.com/reports/", "ip": "198.51.100.7", "ua": "Chrome 131 (Windows)", "data": "{\"report\":\"monthly\",\"timeout\":30000}" }' \ https://logs.example.com/ ``` Response `200`: ```json {"success":true} ``` ## Fields | Field | Required | Max. length | What it holds | |---|---|---|---| | `app` | yes | 40 | The name of the app, for example `Demo project`. Shown in **App**. | | `type` | no | | `info`, `warning`, `error` or `success`, in lower case. Any other value, or none, is stored as `info`. | | `message` | no | 500 | The text of the log. | | `schema` | no | 50 | The part of the app, for example `Orders` or `Users`. | | `userid` | no | 30 | The ID of the user. | | `username` | no | 50 | The name of the user. | | `url` | no | 100 | The address the user was on. | | `ip` | no | 80 | The IP address of the user. | | `ua` | no | 30 | The device or browser, shown in **Device**. | | `data` | no | | Extra data as a **JSON string**. Shown formatted in [Log detail](../../guides/log-detail/). | | `reference` | no | 50 | Your own reference, for example an order number. Only in the [downloaded file](../../guides/download-logs/). | | `date` | no | | The time of the event, as an ISO date. Only in the downloaded file. Without it, the time of arrival is used. | | `clientside` | no | | `true` if the event happened in the browser. Only in the downloaded file. | OpenLogger adds `id` and `dtcreated`, the time it received the log. Other fields are ignored. ## Rules - A longer value is cut to the maximum length, without an error. - `data` must be a string. Turn an object into JSON first, for example with `JSON.stringify()` in JavaScript. An object sent as it is gets stored empty. - Without `app`, the request fails with `400`. See [Errors](../errors/). --- title: Read logs with the admin API project: OpenLogger version: 1.0 section: reference language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/reference/read-logs/ updated: 2026-11-19T08:02:31.630Z --- # Read logs with the admin API > Query, remove, clear and download logs from a script with the primary access token. The admin interface reads the logs through `POST /api/`. Your scripts can do the same with the **primary access token**. An API token does not work here. Every request sends a JSON body with a `schema` that names the action, followed by its arguments as a query string. ## Query logs ```bash curl -H "x-token: PRIMARY_TOKEN" -H "content-type: application/json" \ -d '{"schema":"logs?type=error&fields=app,type,message&limit=1"}' \ https://logs.example.com/api/ ``` Response: ```json {"items":[{"app":"Demo shop","type":"error","message":"Stock check failed for order 1002"}],"count":2,"page":1,"limit":1,"pages":2} ``` `count` is the number of matching logs, `pages` the number of pages. ### Arguments | Argument | Example | What it does | |---|---|---| | a field name | `app=shop` | Filters by `app`, `type`, `schema`, `userid`, `username`, `message`, `url`, `ip`, `ua`, `data` or `id`. Finds the text anywhere in the field and ignores upper and lower case. | | `dtcreated` | `dtcreated=2026-11-19` | Filters by the day the log arrived. A range: `dtcreated=2026-11-18 - 2026-11-20`. | | `sort` | `sort=app_asc` | Sorts by a field, `_asc` or `_desc`. The default is `dtcreated_desc`, newest first. | | `fields` | `fields=app,message` | Returns only these fields. | | `page` | `page=2` | The page to return. | | `limit` | `limit=20` | Logs per page, at most 100. | Each item holds `id`, `app`, `type`, `schema`, `userid`, `username`, `ua`, `message`, `url`, `ip`, `dtcreated` and `data`. ## Remove logs Pass the IDs of the logs, separated by commas: ```bash curl -H "x-token: PRIMARY_TOKEN" -H "content-type: application/json" \ -d '{"schema":"logs_remove?id=24nap001bg51d,24nap002bg50d"}' \ https://logs.example.com/api/ ``` Response: ```json {"success":true} ``` ## Clear all logs ```bash curl -H "x-token: PRIMARY_TOKEN" -H "content-type: application/json" \ -d '{"schema":"logs_clear"}' \ https://logs.example.com/api/ ``` Response: ```json {"success":true} ``` ## Download the log file ```bash curl -H "x-token: PRIMARY_TOKEN" -o logs.nosql https://logs.example.com/api/download/ ``` See [Download logs](../../guides/download-logs/) for what the file holds. --- title: Errors project: OpenLogger version: 1.0 section: reference language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/reference/errors/ updated: 2026-11-19T08:02:31.630Z --- # Errors > The status codes and messages OpenLogger answers with, and what to do. When a request fails, OpenLogger answers with a status code and, in most cases, a JSON array that describes the problem. ## Status codes | Status | Body | Cause | What to do | |---|---|---|---| | `400` | `[{"name":"app","error":"The field \"app\" is invalid","path":"app","prefix":"app"}]` | `app` is missing or empty, or the body is not valid JSON. | Send `app` and check the `content-type` header. | | `401` | An HTML error page | The token is missing or wrong, an API token was used on `/api/`, or your address is blocked. | Check the token. See below. | | `404` | An HTML error page | The `schema` in an admin request is unknown. | Check the name, for example `logs`. | A `200` answer does not mean every value was kept as sent: long values are cut, and unknown types become `info`. See [Send a log](../send-log/). ## Blocked after wrong tokens After six requests with a wrong or missing token, OpenLogger answers `401` to every request from the same IP address, also with a valid token, for up to 15 minutes. This includes the admin interface. Restarting OpenLogger lifts the block. Fix the token in your app, then wait or restart OpenLogger. ## Check a response in your code A wrong token answers with HTML, not JSON. Read the status code first and parse the body as JSON only when you expect it. See [Send from Node.js](../../recipes/send-from-nodejs/). --- title: Send from Node.js project: OpenLogger version: 1.0 section: recipes language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/recipes/send-from-nodejs/ updated: 2026-11-19T08:02:31.630Z --- # Send from Node.js > A small Node.js function that sends a log to OpenLogger and reports errors. This recipe sends logs from a Node.js app with the built-in `fetch`. It needs no extra package. It turns `data` into a JSON string for you. ## The code Save it as `send.mjs`: ```javascript // send.mjs: sends logs to OpenLogger. const OPENLOGGER = process.env.OPENLOGGER_URL; const TOKEN = process.env.OPENLOGGER_TOKEN; async function log(entry) { const body = { app: 'Demo project', ...entry }; if (body.data && typeof body.data !== 'string') body.data = JSON.stringify(body.data); const response = await fetch(OPENLOGGER + '/', { method: 'POST', headers: { 'content-type': 'application/json', 'x-token': TOKEN }, body: JSON.stringify(body), signal: AbortSignal.timeout(10000) }); const text = await response.text(); if (!response.ok) throw new Error(response.status + ' ' + text.substring(0, 200)); return JSON.parse(text); } console.log(await log({ type: 'error', message: 'Payment failed', userid: 'u100', username: 'Jane Doe', data: { order: 1003, reason: 'card declined' } })); try { await log({ app: '', message: 'No app name' }); } catch (e) { console.log(e.message); } ``` ## Run it ```bash OPENLOGGER_URL=https://logs.example.com OPENLOGGER_TOKEN=YOUR_TOKEN node send.mjs ``` The output: ```text { success: true } 400 [{"name":"app","error":"The field \"app\" is invalid","path":"app","prefix":"app"}] ``` The first log is stored with its data; the second call fails because `app` is empty. ## Notes - The body is read as text first, because a wrong token answers `401` with an HTML page. See [Errors](../../reference/errors/). - The timeout stops the request after 10 seconds, so a slow log server does not hold up your app. - Keep the token on the server. Never put it in code that runs in the browser. --- title: Total.js audit logs project: OpenLogger version: 1.0 section: recipes language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/recipes/totaljs-audit/ updated: 2026-11-19T08:02:31.630Z --- # Total.js audit logs > Send the audit logs of a Total.js 4 app to OpenLogger with $.audit(). A Total.js 4 app writes audit logs with `$.audit()`. With one definition file, these logs go to OpenLogger instead of a local file. ## Set it up **1.** In OpenLogger, create an [API token](../../guides/api-tokens/) for the app and copy its address with **Copy URL address**. **2.** Add the address to the `config` file of your Total.js app: ```text name : Demo project openlogger : https://logs.example.com/?token=YOUR_TOKEN ``` **3.** Create the file `definitions/logger.js`: ```javascript DEF.onAudit = function(name, data) { data.app = CONF.name; data.sessionid = data.thread = undefined; RESTBuilder.POST(CONF.openlogger, data).keepalive().callback(ERROR('OpenLogger')); }; ``` The app name in OpenLogger is the `name` from the config file. ## Write audit logs Call `$.audit()` in a schema action, with a message and, optionally, a type (`info`, `warning`, `error` or `success`): ```javascript NEWSCHEMA('Orders', function(schema) { schema.define('product', String, true); schema.define('quantity', Number); schema.action('create', { name: 'Create an order', action: function($, model) { // ... save the order ... $.audit('Order created: ' + model.product); $.success(); } }); }); ``` ## What arrives in OpenLogger Running this action with the product `Demo product` stores this log: | Field | Value | |---|---| | **App** | `Demo project` | | **Type** | `info` | | **Schema** | `Orders.create` | | **Message** | `Order created: Demo product` | | `data` | `{"params":{},"query":{},"model":{"product":"Demo product","quantity":2}}` | `data` holds the arguments and the model of the action. --- title: Access and tokens project: OpenLogger version: 1.0 section: faq language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/faq/access/ updated: 2026-11-19T08:02:25.706Z --- # Access and tokens > A lost primary access token, blocked requests and which token to use where. ## I lost the primary access token. How do I get back in? **1.** Stop OpenLogger. **2.** Open `databases/memorize_data.json` in a text editor. In the `config` section, set `token` to an empty value: ```json "token": "", ``` **3.** Start OpenLogger and open `/setup/`. It opens without a token. **4.** Set a new token right away in **Configuration**. See [First start](../../guides/first-start/). ## The primary access token stopped working after I filled in the OpenPlatform tokens With **Request token** and **Response token** filled in, the admin interface accepts only Total.js OpenPlatform. Follow the steps above, and in step 2 also empty `op_reqtoken` and `op_restoken`. ## Can my app use the primary access token to send logs? No. Sending a log needs an [API token](../../guides/api-tokens/); the primary access token answers `401` there. The other way round, an API token cannot read logs. ## How do I stop a token from working? Open the token in **Tokens**, change **Access token** to a new random value and click **SUBMIT**. The old value stops working at once. See [API tokens](../../guides/api-tokens/). ## My app gets 401 although the token is right. Why? OpenLogger blocks an IP address for up to 15 minutes after six requests with a wrong token, even when the next requests have a valid token. Wait, or restart OpenLogger. See [Errors](../../reference/errors/). --- title: Stored logs project: OpenLogger version: 1.0 section: faq language: en license: MIT url: https://totaljs.es/docs/openlogger/1-0/faq/logs/ updated: 2026-11-19T08:02:25.706Z --- # Stored logs > Why a value looks different from what you sent, and how long logs are kept. ## My data does not appear in the log detail. Why? `data` must be a JSON string. If your app sends an object, OpenLogger answers `200` but stores `data` empty. Turn the object into a string first, for example with `JSON.stringify()`. See [Send a log](../../reference/send-log/). ## I sent the type "debug" and the log shows "info". Why? `type` accepts only `info`, `warning`, `error` and `success`, in lower case. Any other value is stored as `info`. ## Why is my message cut off? Every field has a maximum length, for example 500 characters for `message` and 30 for `ua`. Longer values are cut. See the table in [Send a log](../../reference/send-log/). ## Where do I see `reference` and `date`? Only in the [downloaded file](../../guides/download-logs/). The table, the detail and the admin API do not show them. The **Created** column is the time OpenLogger received the log. ## How long are logs kept? Until you remove them. OpenLogger never deletes logs by itself. See [Remove and clear logs](../../guides/remove-logs/). ## I removed logs, but they are still in the list. Why? The list does not reload by itself after **Remove** or **Clear**. Click **Refresh**.