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
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));
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ExecutorServiceprotected static final org.slf4j.Loggerprotected intprotected booleanprotected RequestLogger.RequestLoggerTaskFields inherited from class services.moleculer.service.MoleculerComponent
broker, nameFields inherited from interface HttpConstants
ACCEPT, ACCEPT_ENCODING, AUTHORIZATION, CACHE_CONTROL, CHUNKED, CLOSE, CONNECT, CONNECTION, CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE, CONTENT_TYPE_HTML, CONTENT_TYPE_JSON, COOKIE, DEFLATE, DELETE, ETAG, GET, GZIP, HEAD, IF_NONE_MATCH, KEEP_ALIVE, LOCATION, META_CONTENT_TYPE, META_HEADERS, META_LOCALE, META_LOCATION, META_SESSION, META_STATUS, META_TEMPLATE, NO_CACHE, OPTIONS, PATCH, POST, PROPERTY_COOKIES, PROPERTY_SESSION_ID, PROPERTY_USER, PUT, SET_COOKIE, TRACE, TRANSFER_ENCODING, WWW_AUTHENTICATE, X_FORWARDED_FOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the ExecutorService.intReturns the max number of printed bytes.install(RequestProcessor next, io.datatree.Tree config) booleanvoidsetExecutor(ExecutorService executor) Sets the ExecutorService.voidsetMaxPrintedBytes(int maxDumpSize) Sets the max number of printed bytes.voidsetShutDownThreadPools(boolean shutDownThreadPools) voidstarted(services.moleculer.ServiceBroker broker) voidstopped()Methods inherited from class services.moleculer.service.MoleculerComponent
getBroker, getLogger, getName
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
maxPrintedBytes
protected int maxPrintedBytes -
executor
-
task
-
shutDownThreadPools
protected boolean shutDownThreadPools
-
-
Constructor Details
-
RequestLogger
public RequestLogger() -
RequestLogger
public RequestLogger(int maxPrintedBytes)
-
-
Method Details
-
started
-
stopped
public void stopped()- Specified by:
stoppedin interfaceservices.moleculer.service.MoleculerLifecycle- Overrides:
stoppedin classservices.moleculer.service.MoleculerComponent
-
install
- Specified by:
installin classHttpMiddleware
-
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
-
setExecutor
Sets the ExecutorService.- Parameters:
executor- the executor to set
-
isShutDownThreadPools
public boolean isShutDownThreadPools() -
setShutDownThreadPools
public void setShutDownThreadPools(boolean shutDownThreadPools)
-