PHPackages                             nelmio/js-logger-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. nelmio/js-logger-bundle

ActiveSymfony-bundle[Logging &amp; Monitoring](/categories/logging)

nelmio/js-logger-bundle
=======================

Adds logging of JS errors in your Symfony application

1.12.0(2mo ago)1791.3M↓66.3%22[3 issues](https://github.com/nelmio/NelmioJsLoggerBundle/issues)[1 PRs](https://github.com/nelmio/NelmioJsLoggerBundle/pulls)MITPHPPHP &gt;=7.2.5

Since Jan 7Pushed 2mo ago8 watchersCompare

[ Source](https://github.com/nelmio/NelmioJsLoggerBundle)[ Packagist](https://packagist.org/packages/nelmio/js-logger-bundle)[ RSS](/packages/nelmio-js-logger-bundle/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (14)Versions (27)Used By (0)

NelmioJsLoggerBundle
====================

[](#nelmiojsloggerbundle)

The **NelmioJsLoggerBundle** bundle allows you to log errors happening in the frontend.

Installation
------------

[](#installation)

Require the `nelmio/js-logger-bundle` package in your composer.json and update your dependencies.

```
$ composer require nelmio/js-logger-bundle

```

Register the bundle in `app/AppKernel.php`:

```
// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Nelmio\JsLoggerBundle\NelmioJsLoggerBundle(),
    );
}

```

Import the bundle's routing definition in `app/config/routing.yml`:

```
# app/config/routing.yml
NelmioJsLoggerBundle:
    resource: "@NelmioJsLoggerBundle/Resources/config/routing.php"
    prefix:   /nelmio-js-logger

```

Automated Error Logging
-----------------------

[](#automated-error-logging)

The bundle exposes two twig functions that you should put in your site template somewhere.

To enable automatic logging of javascript errors, use `nelmio_js_error_logger()`:

```
{{ nelmio_js_error_logger() }}

```

You can optionally change the level (default is ERROR) and remove the surrounding `..` tags - don't forget to add them manually!:

```

    {{ nelmio_js_error_logger('WARNING', false) }}

```

You can also optionally give some extra context information by defining a global `window.nelmio_js_logger_custom_context` in the page:

```

    window.nelmio_js_logger_custom_context = { userinfo: 'some info', appinfo: 'another useful info' };
    {{ nelmio_js_error_logger('ERROR', false) }}

```

Manual Logging from JavaScript
------------------------------

[](#manual-logging-from-javascript)

To expose the `log()` function to your JS code, use `nelmio_js_logger()`:

```
{{ nelmio_js_logger() }}

```

You can also change the function name if `log` is too generic for you:

```
{{ nelmio_js_logger('my_log_function') }}

```

The function signature is as such: `log(level, message, context)`. The level and message are mandatory. The context is a data object that can contain any additional details you want to store.

Configuration
-------------

[](#configuration)

You can restrict the logging levels accessible from javascript. The point is that if some of your logging levels email you or notify you in some way, you probably do not want to allow anyone to send requests and wake you up at 2AM.

Here is the default configuration that exposes all levels:

```
# app/config/config.yml
nelmio_js_logger:
    allowed_levels: ['DEBUG', 'INFO', 'NOTICE', 'WARNING', 'ERROR', 'CRITICAL', 'ALERT', 'EMERGENCY']

```

You can also restrict the logging by ignoring some messages or scripts URLs with this configuration:

```
# app/config/config.yml
nelmio_js_logger:
    ignore_messages:
        - originalCreateNotification
    ignore_url_prefixes:
        - https://graph.facebook.com

```

The URL matches as a prefix to the script URL, and the message will match if the ignored string is found anywhere in the message.

### Optional: Log the whole javascript stack trace with Stacktrace.js

[](#optional-log-the-whole-javascript-stack-trace-with-stacktracejs)

[Stacktrace.js](http://www.stacktracejs.com/) is a small js-library to create javascript stack traces anywhere.

```
# app/config/config.yml
nelmio_js_logger:
    use_stacktrace_js: ~

```

If stacktrace.js is loaded before an error occurs, an array with stack trace information (file, line, column) will be logged additionally to the other information.

By default, the stacktracejs javascript file is loaded from you can change this by setting the path value in the config.yml

```
# app/config/config.yml
nelmio_js_logger:
    use_stacktrace_js:
        path: 'your-url-for-stacktracejs'

```

Properly tracking scripts in other domains
------------------------------------------

[](#properly-tracking-scripts-in-other-domains)

If an error occurs in a script from another domain, browser same origin policy will make it to be logged with a generic message, file and line number (like `Script error. {"file":"","line":"0", ...}`). To properly track these scripts move them to your domain or [load them using CORS](https://developer.mozilla.org/en-US/docs/HTML/CORS_settings_attributes):

```

```

Note that [browser support for `` varies](http://blog.errorception.com/2012/12/catching-cross-domain-js-errors.html):

> As of this writing, only Firefox supports reporting errors for cross-domain scripts. All WebKit browsers including Chrome is expected to support this very soon. This isn't a problem with IE at all, since IE already reports errors to window.onerror irrespective of the domain (yay, security!).

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance83

Actively maintained with recent releases

Popularity56

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 55.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~193 days

Recently: every ~211 days

Total

26

Last Release

86d ago

PHP version history (2 changes)1.5.0PHP &gt;=7

1.10.0PHP &gt;=7.2.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/183678?v=4)[Jordi Boggiano](/maintainers/Seldaek)[@Seldaek](https://github.com/Seldaek)

---

Top Contributors

[![Seldaek](https://avatars.githubusercontent.com/u/183678?v=4)](https://github.com/Seldaek "Seldaek (69 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (20 commits)")[![azine](https://avatars.githubusercontent.com/u/3774977?v=4)](https://github.com/azine "azine (10 commits)")[![oleg-andreyev](https://avatars.githubusercontent.com/u/1244112?v=4)](https://github.com/oleg-andreyev "oleg-andreyev (7 commits)")[![stephanvierkant](https://avatars.githubusercontent.com/u/601833?v=4)](https://github.com/stephanvierkant "stephanvierkant (3 commits)")[![guillaumepotier](https://avatars.githubusercontent.com/u/496234?v=4)](https://github.com/guillaumepotier "guillaumepotier (3 commits)")[![raziel057](https://avatars.githubusercontent.com/u/652505?v=4)](https://github.com/raziel057 "raziel057 (2 commits)")[![przeszpi](https://avatars.githubusercontent.com/u/44025379?v=4)](https://github.com/przeszpi "przeszpi (2 commits)")[![pdias](https://avatars.githubusercontent.com/u/1615884?v=4)](https://github.com/pdias "pdias (1 commits)")[![thePanz](https://avatars.githubusercontent.com/u/226021?v=4)](https://github.com/thePanz "thePanz (1 commits)")[![boenner](https://avatars.githubusercontent.com/u/7580553?v=4)](https://github.com/boenner "boenner (1 commits)")[![chandon](https://avatars.githubusercontent.com/u/4522557?v=4)](https://github.com/chandon "chandon (1 commits)")[![damienalexandre](https://avatars.githubusercontent.com/u/225704?v=4)](https://github.com/damienalexandre "damienalexandre (1 commits)")[![EmmanuelVella](https://avatars.githubusercontent.com/u/663607?v=4)](https://github.com/EmmanuelVella "EmmanuelVella (1 commits)")[![frosas](https://avatars.githubusercontent.com/u/50098?v=4)](https://github.com/frosas "frosas (1 commits)")[![hason](https://avatars.githubusercontent.com/u/288535?v=4)](https://github.com/hason "hason (1 commits)")[![havvg](https://avatars.githubusercontent.com/u/126898?v=4)](https://github.com/havvg "havvg (1 commits)")

---

Tags

logloggingjavascriptJS

### Embed Badge

![Health badge](/badges/nelmio-js-logger-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/nelmio-js-logger-bundle/health.svg)](https://phpackages.com/packages/nelmio-js-logger-bundle)
```

###  Alternatives

[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k251.7M11.6k](/packages/symfony-framework-bundle)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
