Class RequestLogger

java.lang.Object
services.moleculer.service.MoleculerComponent
services.moleculer.service.Service
services.moleculer.web.middleware.HttpMiddleware
services.moleculer.web.middleware.RequestLogger
All Implemented Interfaces:
services.moleculer.service.MoleculerLifecycle, HttpConstants

public class RequestLogger extends HttpMiddleware implements HttpConstants
Writes request headers and response headers + response body into the log. Request body not logged in this version. WARNING: Using this middleware reduces the performance (nevertheless, it may be useful during development). Be sure to turn it off in production mode. Sample:
route.use(new RequestLogger(2048));
  • Field Details

    • logger

      protected static final org.slf4j.Logger logger
    • maxPrintedBytes

      protected int maxPrintedBytes
    • executor

      protected ExecutorService executor
    • task

    • shutDownThreadPools

      protected boolean shutDownThreadPools
  • Constructor Details

    • RequestLogger

      public RequestLogger()
    • RequestLogger

      public RequestLogger(int maxPrintedBytes)
  • Method Details

    • started

      public void started(services.moleculer.ServiceBroker broker) throws Exception
      Specified by:
      started in interface services.moleculer.service.MoleculerLifecycle
      Overrides:
      started in class services.moleculer.service.MoleculerComponent
      Throws:
      Exception
    • stopped

      public void stopped()
      Specified by:
      stopped in interface services.moleculer.service.MoleculerLifecycle
      Overrides:
      stopped in class services.moleculer.service.MoleculerComponent
    • install

      public RequestProcessor install(RequestProcessor next, io.datatree.Tree config)
      Specified by:
      install in class HttpMiddleware
    • getMaxPrintedBytes

      public int getMaxPrintedBytes()
      Returns the max number of printed bytes.
      Returns:
      the max number of printed bytes
    • setMaxPrintedBytes

      public void setMaxPrintedBytes(int maxDumpSize)
      Sets the max number of printed bytes.
      Parameters:
      maxDumpSize - max number of printed bytes
    • getExecutor

      public ExecutorService getExecutor()
      Returns the ExecutorService.
      Returns:
      the executor
    • setExecutor

      public void setExecutor(ExecutorService executor)
      Sets the ExecutorService.
      Parameters:
      executor - the executor to set
    • isShutDownThreadPools

      public boolean isShutDownThreadPools()
    • setShutDownThreadPools

      public void setShutDownThreadPools(boolean shutDownThreadPools)