h1. Logging guidelines h2. Framework h3. SLF4J (Simple Logging Facade for Java) "Documentation":http://www.slf4j.org/docs.html h3. Maven No dependency SHOULD be added to the module POM. The slf4j dependency is already defined in the ecard client root POM. slf4j needs a backend implementation. For the tests, logback-classic is pulled in by the root POM. For production use, the client artifact must pull in a compile dependency on a backend and configure it appropriately. h3. Preamble
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

private static final Logger logger = LoggerFactory.getLogger(MYCLASS.class);
h2. Levels h3. Exceptions
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

private static final Logger logger = LoggerFactory.getLogger(MYCLASS.class);

try{
 ...
} catch (Exception e){
  logger.error(ex.getMessage(), ex);
}
Or set a descriptive message:
try{
 ...
} catch (Exception e){
  logger.error("Error while reading value X.", ex);
}
h3. Messages Messages including APDUs, eCard-API messages, PAOS messages.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

private static final Logger logger = LoggerFactory.getLogger(MYCLASS.class);

logger.debug("Message received:\n{}", message);
logger.debug("Message sent:\n{}", message);
h3. Events E.g. GUI events.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

private static final Logger logger = LoggerFactory.getLogger(MYCLASS.class);

logger.debug("Event: {}", event);
h2. Notes h3. Trace statements as the following example shows are omitted, because there is a "slf4j agent":http://www.slf4j.org/extensions.html#javaagent which can automate this task.
public void foo(Bar b) {
    logger.trace("Enter function foo: {}", b);
    ...