Skip to main content

Tegral Logging

Tegral Logging is a feature that makes it easy to add logging to a Tegral application.

Tegral Logging exposes SLF4J loggers and uses Logback behind the scenes.

Package information
Package nameCatalog dependencyFull Gradle name


You will need to install the feature like so:


Tegral Logging is installed by default when using Tegral Web AppDefaults/AppDSL, requiring no additional action

Creating loggers

Once installed, Tegral Logging will add a Logger factory within the DI environment. Here is an example of a class that uses Tegral Logging to get its logger:

class MyClass(scope: InjectionScope) {
private val logger: Logger by scope()

fun printSomething() {"Hello World!")

The name of the logger is automatically determined for the fully qualified name (FQN) of the class that is requesting said logger. Optionally, you can also specify a custom logger name by adding the @LoggerName annotation to your class:

class MyClass(scope: InjectionScope) {
private val logger: Logger by scope()

// ...

Logger configuration

Tegral Logging exposes configuration properties that can be used to directly configure logging within your application (without needing to use Logback's logback.xml).

Global logging level

You can confiure the "global" logging level for the entire application like so:

level = "Debug"

Available values are (from most verbose to least verbose):

  • All
  • Trace
  • Debug
  • Info (default)
  • Warn
  • Error

Individual loggers

You can also configure individual loggers.

level = "Debug"

This will configure the org.example.hello logger to use the Debug logging level. Make sure you do not forget the quotation marks!

Available logging level values are the same as for the global logging levels.


Please note that the objective of this configuration section is to provide an easy way of configuring loggers. In case you need more advanced behavior, you should either:

  • Use a logback.xml file.
  • Create your own feature that programmatically configures loggers on the onConfigurationLoaded lifecycle hook