Skip to content

Instantly share code, notes, and snippets.

@rselva
Last active November 7, 2017 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rselva/4528e90085627107ae7514ce15b104d1 to your computer and use it in GitHub Desktop.
Save rselva/4528e90085627107ae7514ce15b104d1 to your computer and use it in GitHub Desktop.
Logback sample
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Levels: ERROR >> WARN >> INFO >> DEBUG >> TRACE
*/
public class LogDemoApplication {
private static final Logger logger = LoggerFactory.getLogger(PcsBatchApplication.class);
public static void main(String[] args) {
logger.error("Network connection not available shutting down..",new RuntimeException("Really bad happened"));
logger.warn("Node 1 is failing trying with node 2");
logger.info("New Batch job started at ", "10:10.10");
logger.debug("File updated by {} validate successs for structure ", "ABCBank");
logger.trace("Data found decrpting using key name{}", "SelvaKey");
}
}
/* Log output
20:56:15.524 [main] ERROR com.example.common.LogDemoApplication - Network connection not available shutting down..
java.lang.RuntimeException: Really bad happened
at com.experian.visa.pcs.batch.common.PcsBatchApplication.main(PcsBatchApplication.java:20)
20:56:15.524 [main] WARN com.example.common.LogDemoApplication - Node 1 is failing trying with node 2
20:56:15.524 [main] INFO com.example.common.LogDemoApplication - New Batch job started at
20:56:15.540 [main] DEBUG com.example.common.LogDemoApplication - File updated by ABCBank validate successs for structure
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment