Breaking News
Home / Java / Java Snippets (page 3)

Java Snippets

How do disable low level logging for Apache Common Packages?

Answer Log4j can be configured via a properties file or an xml file. The below is an example of configuring Log4j using a properties file. Generally for simplicity the file name is called as log4j.properties but can be anything. Typical Configuration log4j.rootLogger=trace,R log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=../logs/server.log log4j.appender.R.MaxFileSize=1024KB log4j.appender.R.MaxBackupIndex=5 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%d[%t]%-5p%c{1}%x-%m%n Disable Apache …

Read More »

How does a typical standalone Java program shell script look like?

#!/bin/sh echo “########################################################”echo “Sample Run Script”echo “Copyright reserved Developerfeed.com@2010-2012!”echo “########################################################” # relative classesroot_dir=../lib_dir=../lib # include all libs in jar filefor i in ../lib/*.jar; do  classpath=$classpath:$idone classpath=$classpath:../build/classesclasspath=$classpath:$root_dir/config env_options=-Dlog4j.properties=log4j.propertiesjava_cmd_line=”java -cp $classpath $env_options” #launch the programecho “########################################################”echo “Launching the program”echo “########################################################”$java_cmd_line com.xyz.server.Startup [pb_builder]

Read More »