LogDigger Servlet Filters

The LogDigger connector for Java comes with two servlet filters:

Request Log Collector Filter
Collects request-related logging events for realtime log review, and configures the browser extension for application usage tracking on the LogDigger Server.
LogDigger Client Filter
Extends the above functionality, adding the ability to send collected log events and other information directly to the LogDigger Server.

Request Log Collector Filter

When initiated by the LogDigger browser extension, RequestLogCollectorFilter collects request-related logging events (using Log4j MDC) and can deliver these log messages to the browser for realtime log review. Users can choose to log events at a level that is higher or lower than the default server configuration.

Basic filter configuration in web.xml:

<!-- Define LogDigger servlet filter -->
<filter>
    <filter-name>LogDiggerServletFilter</filter-name>
    <filter-class>com.logdigger.connector.servlet.filter.RequestLogCollectorFilter</filter-class>
    <!-- init params go here -->
</filter>

<!-- Define mapping for the LogDigger filter -->
<filter-mapping>
    <filter-name>LogDiggerServletFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

The above filter will allow the collection of server log messages and their delivery to the client.

Note

The LogDigger servlet filter will not be able to register log events generated by servlet filters that are higher in the filter chain. Therefore, the LogDigger filter must be defined as early as possible in the filter list (for example, right after the character encoding filter).

If you have the LogDigger Server configured for application usage tracking and integration with an external bug tracker, you can send its details to the clients using the following servlet filter parameters:

<init-param>
    <param-name>serverUrl</param-name>
    <param-value>http://servername/logdigger/</param-value>
</init-param>
<init-param>
    <param-name>projectKey</param-name>
    <param-value>your_project_logging_key</param-value>
</init-param>

When the user enables LogDigger for the application site, the above parameters will be automatically sent to the client (browser extension), and usage tracking will begin after the user approves it.

Log Access Control

By default, RequestLogCollectorFilter will allow anyone with the LogDigger browser extension to pull log messages from your application. To prevent this, you need to set up a request authorizer that will disable the LogDigger connector’s functions unless the HTTP request passes certain criteria (for example, the application is running in a development environment, or the request is coming from a trusted network).

Warning

Use of the request authorizer is highly recommended!

The parameter authorizer of RequestLogCollectorFilter allows you to specify the name of a class that implements the com.logdigger.connector.servlet.filter.RequestAuthorizer interface.

The LogDigger Connector comes with Simple Authorizer as a reference implementation that you can use in your deployments.

LogDigger Client Filter

The LogDiggerClientFilter extends the previously described RequestLogCollectorFilter, adding the ability to upload server logs and other information directly to the LogDigger Server:

<filter>
    <filter-name>LogDiggerServletFilter</filter-name>
    <filter-class>com.logdigger.connector.servlet.filter.LogDiggerClientFilter</filter-class>
    <init-param>
        <param-name>serverUrl</param-name>
        <param-value>http://servername/logdigger/</param-value>
    </init-param>
    <init-param>
        <param-name>projectKey</param-name>
        <param-value>your_project_logging_key</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>LogDiggerServletFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

You don’t need to install both RequestLogCollectorFilter and LogDiggerClientFilter, as the latter includes all the necessary functionality.

Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 2.5