Package at.hobex.pos.logger
package at.hobex.pos.logger
This package provides the ability to use different logger implementation.
By default the API uses the Log4J (v1.2.17) framework. If you want to use another framework or a own implemented solution it can be done by implementing the ILogger interface and set the logger in the LogManager.
By default the API uses the Log4J (v1.2.17) framework. If you want to use another framework or a own implemented solution it can be done by implementing the ILogger interface and set the logger in the LogManager.
Example for using an own Logging-Framework
import at.hobex.pos.logger.ILogger;
import at.hobex.pos.logger.LogManager;
public class LogManagerTest {
private static ILogger log;
public static void main(String[] args) {
LogManager.setLogger(new MyLogger());
log = LogManager.getLogger();
log.debug("Logtest debug");
log.info("Logtest info");
log.warn("Logtest warn");
log.error("Logtest error");
log.fatal("Logtest fatal");
log.debug("Logtest debug", new IllegalArgumentException("The exception message"));
log.info("Logtest info", new IllegalArgumentException("The exception message"));
log.warn("Logtest warn", new IllegalArgumentException("The exception message"));
log.error("Logtest error", new IllegalArgumentException("The exception message"));
log.fatal("Logtest fatal", new IllegalArgumentException("The exception message"));
}
}
class MyLogger implements ILogger {
@Override
public void debug(Object message) {
System.out.println("DEBUG - " + message);
}
@Override
public void debug(Object message, Throwable exception) {
System.out.println("DEBUG - " + message + " Exception: " + exception);
}
@Override
public void info(Object message) {
System.out.println("INFO - " + message);
}
@Override
public void info(Object message, Throwable exception) {
System.out.println("INFO - " + message + " Exception: " + exception);
}
@Override
public void warn(Object message) {
System.out.println("WARN - " + message);
}
@Override
public void warn(Object message, Throwable exception) {
System.out.println("WARN - " + message + " Exception: " + exception);
}
@Override
public void error(Object message) {
System.err.println("ERROR - " + message);
}
@Override
public void error(Object message, Throwable exception) {
System.err.println("ERROR - " + message + " Exception: " + exception);
}
@Override
public void fatal(Object message) {
System.err.println("FATAL - " + message);
}
@Override
public void fatal(Object message, Throwable exception) {
System.err.println("FATAL - " + message + " Exception: " + exception);
}
}
-
ClassDescriptionThis class provides the interface to serve the ability to use an own logger implementation.This class offers the possibility to set and get the desired logger.