Category Archives: java

Setting log4j log level programmatically

12345678910111213141516private static void setupLog4j() {         System.out.println("setupLog4j");         BasicConfigurator.resetConfiguration();         // Start clean.         Logger.getRootLogger().removeAllAppenders();         // Create appender         ConsoleAppender console … Continue reading

Posted in java | Leave a comment

Print java stack trace from anywhere

Need to know which code call a specific location? Dump the stack trace: 1LOG.trace(ExceptionUtils.getStackTrace(new Throwable()));

Posted in java | Leave a comment

Knowing you exception class name

To know what is your exception class name, in case you want to have a more specific catch. 1234        } catch (Exception e){             LOG.error("SQL error when processing " + requestId+". Exception … Continue reading

Posted in java | Tagged | Leave a comment

Print call stack in Java from anywhere

1 LOG.trace(ExceptionUtils.getStackTrace(new Throwable()));

Posted in java | Leave a comment