This is a simple logger with minimal configuration. It is an
SLF4J backend that forwards logs to a
ServletContext
object.
Declare a dependency on slf4j-servletcontext
:
<dependency>
<groupId>com.commongroundpublishing</groupId>
<artifactId>slf4j-servletcontext</artifactId>
<version>1.0.0</version>
</dependency>
To initialize slf4j-servletcontext
, add to web.xml
:
<listener>
<listener-class>com.commongroundpublishing.slf4j.impl.ServletContextLoggerSCL</listener-class>
</listener>
All log messages will now be logged using ServletContext#log.
The logging level can be set with a context parameter. Possible
values are (case insensitive) trace
, debug
, info
, warn
,
error
, following the standard slf4j levels.
<context-param>
<param-name>ServletContextLogger.LEVEL</param-name>
<param-value>debug</param-value>
</context-param>