org.logevents:logevents

Simple implementation of slf4j


Keywords
java, library, logging, slf4j
Licenses
Apache-2.0/libpng-2.0

Documentation

Logevents - a simple SLF4J implementation

Apache 2.0 License Maven Central Javadoc Build Status Coverage Status Vulnerability scan

Setting up and configuring logging should be easy, whether you want to do it with configuration files or in code. Log Events is a small (265kb, no dependencies) logging framework built on top of SLF4J - the logging lingua franka for Java.

For detailed instructions, see the manual.

Quick start

Add dependencies (for Maven)

<dependencies>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>2.0.7</version>
    </dependency>

    <dependency>
        <groupId>org.logevents</groupId>
        <artifactId>logevents</artifactId>
        <version>0.5.0</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>

Simple configuration

root=WARN file,console
logger.org.example=INFO
logger.org.example.myapp=DEBUG,TRACE@marker=HTTP_REQUEST&mdc:user=admin
logevents.status=CONFIG

By default, the file observer will log to a file named logs/your-app-name-%date.log and console logs ANSI-colored logs to the console.

The default level for loggers with this configuration will be WARN, by org.example will log at INFO and org.example.myapp will log at DEBUG, or trace for HTTP_REQUEST when the user is admin. See LogEventFilter for details. Use level NONE to turn off logging.

Logevents will output configuration information to system err.

Configuration in a Twelve-Factor setting

Here is an example setup in a cloud environment. Logevents can be configured with environment variables and use stdout as the main channel for logging, outputting JSON logs for more powerful downstream parsing

# Output logevents configuration debug to stderr
LOGEVENTS_STATUS=CONFIG
# Skip sun.reflect packages in stack traces
LOGEVENTS_PACKAGEFILTER=sun.reflect

# By default only output to console at DEBUG
LOGEVENTS_ROOT=DEBUG console

# Console format should be JSON for easier log parsing
LOGEVENTS_OBSERVER_CONSOLE_FORMATTER=ConsoleJsonLogEventFormatter

# Install logging to Microsoft Teams for all ERROR messages
LOGEVENTS_ROOT_OBSERVER_TEAMS=ERROR
LOGEVENTS_OBSERVER_TEAMS=MicrosoftTeamsLogEventObserver
LOGEVENTS_OBSERVER_TEAMS_URL=https://example.webhook.office.com/webhookb2/...

# Turn down logging for selected packages
LOGEVENTS_LOGGER_ORG_ECLIPSE_JETTY=WARN
# Turn up logging to TRACE for com.example message for selected users are
LOGEVENTS_LOGGER_COM_EXAMPLE=DEBUG,TRACE@mdc:user=superuser|admin|tester

Features: