general library

MVC frameworks

spark: microframework ispirato a Sinatra:

REST libs

Utils

  • JRebel: live reload of the java server

log4j

ensure log4j.jar is in class path

private static org.apache.log4j.Logger logger = Logger.getLogger( this.getClass().getName()
);

config: workspace/projectdirectory/bin/log4j.properties

log4j.rootLogger=debug, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%t %-5p %c{2} - %m%n

log4j conf file to specify a configuration file

  • name exactly "log4j.properties" in your classpath
  • add a System property to command line
-Dlog4j.configuration=$conf_dir/log4j.properties

basic config in code

String logConfPath = System.getProperty("log4j.configuration");
if( logConfPath == null || logConfPath.isEmpty() ) {
    // se non è settato log4j.configuration
    // Set up a simple configuration that logs on the console.
    BasicConfigurator.configure();
}
this.logger.debug("logger init");