-
Notifications
You must be signed in to change notification settings - Fork 1
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.
The five logging levels used by Log are (in order):
- trace (the least serious)
- debug
- info
- warn
- error (the most serious)
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.
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.