How to find GTYPE of SDO_GEOMETRY objects in a table:
select sdo_geometry.get_gtype(geom), count(*) from map_data.zip_geom group by sdo_geometry.get_gtype(geom)/
A totally arbitrary set of notes themed around various topics of software development widely ranging from code examples and how-to's to development processes and maybe even some computing-inspired philosophical musings.
"It's an island, babe. If you don't bring it here, you won't find it here."
"Whoa, heavy. Pilot and philosopher!"
(From the Six Days Seven Nights movie)
FileAppender
by using a timestamp as part of the log file name injected from a system property.# A sample Log4j configuration demonstrating how to create a new log file # at each program start. # Created: Apr 6, 2016 by Vitali Tchalov log4j.rootLogger=info, stdout, logfile log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout= org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern= %5p [%t] (%d) %c - %m%n log4j.appender.logfile=org.apache.log4j.FileAppender log4j.appender.logfile.File=logs/job_${log.timestamp}.log log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern=%d [%t] %5p %c - %m%n
log.timestamp
to append a unique (with a second precision) suffix to the log file name.main(String[])
method) prior to referencing any Logger
.static { System.setProperty("log.timestamp", new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date())); }
package com.forms2docx; import java.text.SimpleDateFormat; import java.util.Date; import org.apache.log4j.Logger; /** * A sample class to demonstrate a technique to configure Log4j to create a new log file at each program run. * * To compile the sample program, specify the absolute path to a log4j.jar file, for example: * javac -d bin -cp ".;./lib/log4j-1.2.17.jar;" ./com/forms2docx/*.java * * To run with the static block that programmatically adds the log.timestamp property: * java -cp ".;./bin;./lib/log4j-1.2.17.jar;" com.forms2docx.Log4jNewFile * * To run with the log.timestamp property passed from the command line: * java -cp ".;./bin;./lib/log4j-1.2.17.jar;" -Dlog.timestamp=$(date +"%Y%m%d_%H%M%S") com.forms2docx.Log4jNewFile * * @author Vitali Tchalov */ public class Log4jNewFile { static { System.setProperty("log.timestamp", new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date())); } private static final Logger logger = Logger.getLogger(Log4jNewFile.class); public static void main(String[] args) { logger.info(String.format("Job has started at %s.", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()))); logger.info("The sample demonstrates how to configure Log4j to create a new file on every program run."); } }
java -cp ".;./bin;./lib/log4j-1.2.17.jar;" com.forms2docx.Log4jNewFile
java -cp ".;./bin;./lib/log4j-1.2.17.jar;" -Dlog.timestamp=$(date +"%Y%m%d_%H%M%S") com.forms2docx.Log4jNewFile
<tstamp />
to the Ant build file<sysproperty key="log.timestamp" value="${DSTAMP}_${TSTAMP}" />
DSTAMP
and TSTAMP
are standard variables defined by Ant.<project name="Launch Java Ant task sample" basedir="." default="info"> <echo message="Launching Java Ant task sample..." /> <tstamp/> <target name="info"> <echo message="The runJob Java task demonstrates creating a new log file at each run."/> </target> <target name="runJob" description="Demonstrates a new log file per each run."> <java classname="com.forms2docx.Log4jNewFile" fork="true" failonerror="true"> <jvmarg value='-Dlog4j.configuration=file:"${basedir}/log4j.properties"' /> <jvmarg value='-server' /> <sysproperty key="log.timestamp" value="${DSTAMP}_${TSTAMP}" /> <classpath> <pathelement location="${basedir}/bin"/> <fileset dir="${basedir}/lib"> <include name="*.jar" /> </fileset> </classpath> </java> <echo message="Task completed."/> </target> </project>Note that by default, the
TSTAMP
is in "HHmm" format. When this precision is not sufficient, then a custom property with a required format can be added.<tstamp> <format property="tstamp-sec" pattern="HHmmss"/> </tstamp>
sysproperty
in the java
task would look like this:<sysproperty key="log.timestamp" value="${DSTAMP}_${tstamp-sec}" />/* --- end --- */