Documentation Menu

Generated script tag

Standard non-Core installation generates script tag

When you install JSNLog using one of the non-Core Nuget packages JSNLog.Log4Net, JSNLog.NLog, JSNLog.Elmah, JSNLog.Serilog or JSNLog.CommonLogging, two things happen:

  • Among other things, it adds a <jsnlog> tag to your web.config, containing the location of your jsnlog.js file:

    <jsnlog productionLibraryPath="~/Scripts/jsnlog.min.js">

  • The installation page will have suggested you include a call to the Configure method in your pages (exceptions). That method inserts a <script> tag that loads the jsnlog.min.js file. It uses the url from the productionLibraryPath property. You can verify this by doing a View Source of the page.

Generating script tags with Core applications

When you install JSNLog in a .Net Core project, the installation procedure relies on you to load the jsnlog.js onto your pages (using a <script> tag or otherwise).

In this case, to have the <script> tag generated for you:

  1. The UseJSNLog method called in your Startup.cs file takes an JsnlogConfiguration object. Set its productionLibraryPath attribute to the url you want to use in the <script> tag.
  2. Add the tag helper jl-javascript-logger-definitions to your pages (how).

Stopping automatic generation of the script tag

If you want to load the jsnlog.min.js file yourself, for example as part of a bundle or as an AMD module, you don't want the generated <script> tag.

You can make it go away by simply not setting the productionLibraryPath attribute.

<jsnlog productionLibraryPath="~/Scripts/jsnlog.min.js">
  new JsnlogConfiguration {

Alternatively, you could simply remove the call to the Configure method or the jl-javascript-logger-definitions tag helper, but that has a few more implications.