Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

JFRLog - a SLF4J to JFR Bridge

This project implements a SLF4J logger which records all log messages as Java Flight Recorder events.


  1. replace your SLF4J compatible logging impl with slf4j-jfr-bridge-x.x.x.jar
  2. start the JVM with JFR enabled (e.g. -XX:StartFlightRecording:filename=logs/recording.jfr,dumponexit=true) or enable recording later
  3. check the flight recorder repository or recording dump for log.* events:
$ jfr print --events "log.*" logs/recording.jfr
log.Info {
  startTime = 07:38:02.730
  message = "Started @5532ms"
  origin = "org.eclipse.jetty.server.Server"
  throwable = N/A
  eventThread = "main" (javaThreadId = 1)

note: JFRLog has currently no fallback, if no recording is active you won't see any logs.

maven central coordinates

<!-- depends on slf4j-api already, but feel free to add it anyway -->


JFRLog can be configured in two ways: via JVM -D arguments or via a file in the classpath. JVM -D properties are handled with higher priority and override properties with the same key stored in the file. (note: disabling specific log events in the JFR recording profile will filter the loggers too)


java -Djfrlog.default=info (...) app.jar

Sets MyKlass to debug, the rest of the package to error and the default log level to info for everything else. The most specific rule wins (order does not matter).

other options:


Records the origin (logger name) of the log message. Enabled by default.


This is off by default and should be kept off unless there is a good reason to enable it. It is going to guarantee that the same logger instance is returned for a given logger name.

commandline tools

JFRLog also provides commandline tools for easy JFR record inspection.

Add the jbang catalog:

$ jbang catalog add jfrlog

and use jfrprint to print JFR events (not only log message events).

$ MSG_PATTERN="{eventName,0d,C} {startTime,dt:yyyy-MM-dd HH:mm:ss.SSS} [{eventThread.javaName}]\
 {origin,1d}: {message} {throwable,o,n}"
$ jbang jfrprint 10h log.* "$MSG_PATTERN" dump.jfr
INFO 2020-09-30 16:12:42.458 [main] jfrlogtest.LogTest: Hello There!
WARN 2020-09-30 16:12:42.461 [main] jfrlogtest.LogTest: don’t panic
java.lang.IllegalArgumentException: test, please ignore
	at dev.mbien.jfrlogtest.LogTest.main(

More info in this blog entry


JFRLog requires Java 8+ to run, but Java 14+ to build/test since the junit tests rely on the JFR streaming API (JEP 349).


This project is distributed under the MIT License, see LICENSE file.