By default, the JSS Node.js rendering engine captures console output / errors emitted by the Node instance(s) rendering your JSS app and logs the output / errors to the default Sitecore log.

I would like to replace the built-in JSS/Sitecore logger with a custom logger, how can I go about doing so?

1 Answer 1


To implement a custom logger, you'll need to implement a type that extends the Sitecore.JavaScriptServices.ViewEngine.NodeServices.ILogger interface from the Sitecore.JavaScriptServices.ViewEngine.NodeServices assembly.

(For reference, use your favorite disassembler to inspect the default JSS/Sitecore implementation that logs Node.js output to Sitecore logs in the Sitecore.JavaScriptServices.ViewEngine.Node.Logger class in the Sitecore.JavaScriptServices.ViewEngine.Node assembly.)

You'll then need to register your ILogger implementation with the Sitecore DI container with something like this (where MyCustomLogger is your custom implementation of ILogger:

using Microsoft.Extensions.DependencyInjection;
using Sitecore.DependencyInjection;
using Sitecore.JavaScriptServices.ViewEngine.NodeServices;

namespace MyNamespace
    public class RegisterDependenciesPatch : IServicesConfigurator
        public void Configure(IServiceCollection serviceCollection)
            var toRemove = serviceCollection.FirstOrDefault(d => d.ServiceType == typeof(ILogger));
            serviceCollection.AddTransiet<ILogger, MyCustomLogger>();

Lastly, you'll need to patch the App_Config/Sitecore/JavaScriptServices/Sitecore.JavaScriptServices.ViewEngine.Node.config file to add your dependency registration code after the default JSS Node services dependency registrations. Example:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      type="MyNamespace.RegisterDependenciesPatch, MyLibrary"
      patch:after="*[@type='Sitecore.JavaScriptServices.ViewEngine.Node.RegisterDependencies, Sitecore.JavaScriptServices.ViewEngine.Node']"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.