Skip to content
This repository has been archived by the owner on Mar 5, 2020. It is now read-only.
Leon Kiefer edited this page Jan 4, 2019 · 4 revisions

Use the Logger

You can use the DI to get a logger. It is important that you use the correct Logger org.slf4j.Logger.

import org.slf4j.Logger;

@Service
public class MyService {
	@Reference
	private Logger logger;

...
		this.logger.info("important info");

If DI can't be used or the Class is not a Service use the LoggerFactory to get a logger for that class.

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MyClass {
	private final Logger logger = LoggerFactory.getLogger(MyClass.class);
...

The logger api is very simple.

Log level

The five logging levels used by Log are (in order):

  1. trace (the least serious)
  2. debug
  3. info
  4. warn
  5. error (the most serious)

Set the visible log level

By default only warnings and errors are shown in the log. You can change this by setting the log level of the logger. You don't have to change any code, the logger prints all logged data higher or equal to the log level to the console. Use the console and type:

log <logLevel>

to set the global log level. Every package can have its own log level.

log <packageName> <logLevel>

More specific setting will override the other settings.

Debugging

To debug a problem you want more verbose output from amy. Therefore you can lower the logger log level in the logger/src/main/resources/logback.xml or use the console command.