# @nextcloud/logger

> Generic JavaScript logging interface for Nextcloud apps and libraries

Latest version **3.0.3** (published 2025-12-10) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @nextcloud/logger
pnpm add @nextcloud/logger
yarn add @nextcloud/logger
bun add @nextcloud/logger
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.3 |
| Published | 2025-12-10 |
| First published | 2019-10-02 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^20.0.0 \|\| ^22.0.0 \|\| ^24.0.0 |
| Dependencies | 1 |
| Unpacked size | 75.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Nextcloud GmbH and Nextcloud contributors |
| Maintainers | icewind1991, skjnldsv, christophwurst, juliushaertl, nickvergessen, artonge, gretadoci, mejo-, susnux |
| Keywords | nextcloud |

## Links

- npm: https://www.npmjs.com/package/@nextcloud/logger
- Repository: https://github.com/nextcloud-libraries/nextcloud-logger
- Homepage: https://github.com/nextcloud-libraries/nextcloud-logger#readme
- Issues: https://github.com/nextcloud-libraries/nextcloud-logger/issues
- npm.io page: https://npm.io/package/@nextcloud/logger

## Dependencies (1)

- [@nextcloud/auth](https://npm.io/package/@nextcloud/auth.md) ^2.5.3

## Recent versions

- 3.0.3 (latest) — 2025-12-10
- 3.0.2 — 2024-05-16
- 3.0.1 — 2024-04-24
- 3.0.0 — 2024-04-22
- 3.0.0-beta — 2024-04-22
- 2.7.0 — 2023-09-20
- 2.6.1 — 2023-09-20
- 2.5.0 — 2023-01-11
- 2.4.0 — 2022-10-24
- 2.3.0 — 2022-08-25
- 2.2.1 — 2022-07-07
- 2.2.0 — 2022-06-27
- 2.1.0 — 2021-09-28
- 2.0.0 — 2021-04-07
- 1.1.2 — 2020-03-19
- … 4 more at https://npm.io/package/@nextcloud/logger/versions

## README

<!--
  - SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
  - SPDX-License-Identifier: GPL-3.0-or-later
-->
# @nextcloud/logger

[![REUSE status](https://api.reuse.software/badge/github.com/nextcloud-libraries/nextcloud-logger)](https://api.reuse.software/info/github.com/nextcloud-libraries/nextcloud-logger) [![Build Status](https://img.shields.io/github/actions/workflow/status/nextcloud-libraries/nextcloud-logger/node.yml?branch=master)](https://github.com/nextcloud-libraries/nextcloud-logger/actions/workflows/node.yml) [![Code coverage](https://img.shields.io/codecov/c/gh/nextcloud-libraries/nextcloud-logger/master)](https://app.codecov.io/gh/nextcloud-libraries/nextcloud-logger) [![npm](https://img.shields.io/npm/v/@nextcloud/logger.svg)](https://www.npmjs.com/package/@nextcloud/logger)
[![Documentation](https://img.shields.io/badge/Documentation-online-brightgreen)](https://nextcloud.github.io/nextcloud-logger/)

Generic JavaScript logging interface for Nextcloud apps and libraries

## Usage
See also [API documentation](https://nextcloud-libraries.github.io/nextcloud-logger/).

```js
import { getLoggerBuilder } from '@nextcloud/logger'

const logger = getLoggerBuilder()
    .setApp('mail')
    .detectUser()
    .build()

logger.debug('hello')
logger.error('this should not have happened', { someContext: 13 })
logger.warn('it\'s just a warning, carry on')
```

Right now the package uses `window.console` as log appender and produces the following output

```
[DEBUG] mail: hello { app: 'mail', uid: 'christoph' }
[ERROR] mail: this should not have happened { app: 'mail', uid: 'christoph', someContext: 13 }
[WARN] mail: it's just a warning, carry on { app: 'mail', uid: 'christoph' }
```

The logger tries to detect the server configured logging level by default,
which can be configured using the `loglevel_frontend` option in the `config.php`.
In case no logging level was configured or detection failed, the logger will fallback to the *warning* level.

If the server is set to the debug mode the configured logging level will be set to the *debug* level.

Any message with a lower level than the configured will not be printed on the console.

You can override the logging level in both cases by setting it manually using the `setLogLevel` function
when building the logger.

## Contributing

This repository is maintained using [conventional commit messages](https://www.conventionalcommits.org/en/v1.0.0/).

---
_Source: https://npm.io/package/@nextcloud/logger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
