Author: desruisseaux
Date: Mon Feb 23 11:11:14 2015
New Revision: 1661640
URL: http://svn.apache.org/r1661640
Log:
Allow the user to control the logging configuration of the SIS command-line
tool.
Added:
sis/branches/JDK8/application/sis-console/src/main/artifact/conf/
sis/branches/JDK8/application/sis-console/src/main/artifact/conf/logging.properties
(with props)
Modified:
sis/branches/JDK8/application/sis-console/src/main/artifact/bin/sis
sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/Command.java
Modified: sis/branches/JDK8/application/sis-console/src/main/artifact/bin/sis
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-console/src/main/artifact/bin/sis?rev=1661640&r1=1661639&r2=1661640&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-console/src/main/artifact/bin/sis [UTF-8]
(original)
+++ sis/branches/JDK8/application/sis-console/src/main/artifact/bin/sis [UTF-8]
Mon Feb 23 11:11:14 2015
@@ -29,4 +29,6 @@ then
fi
# Execute SIS with any optional JAR that the user may put in the 'lib'
directory.
-java -classpath "$BASE_DIR/lib/*" org.apache.sis.console.Command $SIS_OPTS "$@"
+java -classpath "$BASE_DIR/lib/*" \
+ -Djava.util.logging.config.file="$BASE_DIR/conf/logging.properties" \
+ org.apache.sis.console.Command $SIS_OPTS "$@"
Added:
sis/branches/JDK8/application/sis-console/src/main/artifact/conf/logging.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-console/src/main/artifact/conf/logging.properties?rev=1661640&view=auto
==============================================================================
---
sis/branches/JDK8/application/sis-console/src/main/artifact/conf/logging.properties
(added)
+++
sis/branches/JDK8/application/sis-console/src/main/artifact/conf/logging.properties
[ISO-8859-1] Mon Feb 23 11:11:14 2015
@@ -0,0 +1,63 @@
+#
+# Logging configuration file for Apache SIS command line.
+#
+# This file is similar to the default configuration file
+# provided in Java installation directory, but contains
+# configuration that are specific to Apache SIS library.
+# The default configuration file is located at:
+#
+# - $JAVA_HOME/jre/lib/logging.properties before Java 9
+# - $JAVA_HOME/conf/logging.properties since Java 9
+#
+# This file can be freely edited as documented below,
+# or as documented in the above-cited standard files.
+#
+
+
+# Comma separated list of log Handler classes.
+# Handlers specify where the logs will be sent.
+# Some available handlers are:
+#
+# - java.util.logging.ConsoleHandler
+# - java.util.logging.FileHandler
+# - java.util.logging.SocketHandler
+#
+# See their javadoc for more information on those handlers.
+
+handlers = java.util.logging.ConsoleHandler
+
+
+# Filter the log records according their logging levels.
+# Each package can have its logs filtered at a different level.
+# By default Apache SIS logs at levels CONFIG and above will be
+# shown, while only levels INFO and above will be shown for other
+# packages. Furthermore the ConsoleHandler also has a separate level
+# setting to limit messages printed to the console.
+
+.level = INFO
+org.apache.sis.level = CONFIG
+java.util.logging.ConsoleHandler.level = INFO
+
+
+# Appearance of log messages. Some available formatters are:
+#
+# - java.util.logging.XMLFormatter
+# - java.util.logging.SimpleFormatter
+# - org.apache.sis.util.logging.MonolineFormatter
+#
+# By default, the Apache SIS formatter displays only the level
+# and the message. Additional fields can be specified here:
+#
+# time: If set, writes the time elapsed since the initialization.
+# The argument specifies the output pattern. For example,
+# the pattern HH:mm:ss.SSSS displays the hours, minutes,
+# seconds and milliseconds.
+#
+# source: If set, writes the source logger or the source class name.
+# The argument specifies the type of source to display.
+# Valid values are none, logger:short, logger:long,
+# class:short and class:long.
+
+java.util.logging.ConsoleHandler.formatter =
org.apache.sis.util.logging.MonolineFormatter
+org.apache.sis.util.logging.MonolineFormatter.source = class:short
+org.apache.sis.util.logging.MonolineFormatter.colors = true
Propchange:
sis/branches/JDK8/application/sis-console/src/main/artifact/conf/logging.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sis/branches/JDK8/application/sis-console/src/main/artifact/conf/logging.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=ISO-8859-1
Modified:
sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/Command.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/Command.java?rev=1661640&r1=1661639&r2=1661640&view=diff
==============================================================================
---
sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/Command.java
[UTF-8] (original)
+++
sis/branches/JDK8/application/sis-console/src/main/java/org/apache/sis/console/Command.java
[UTF-8] Mon Feb 23 11:11:14 2015
@@ -17,6 +17,8 @@
package org.apache.sis.console;
import java.util.Locale;
+import java.util.logging.LogManager;
+import java.util.logging.ConsoleHandler;
import java.io.Console;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -62,7 +64,7 @@ import org.apache.sis.util.logging.Monol
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.4
+ * @version 0.6
* @module
*/
public final class Command {
@@ -229,7 +231,24 @@ public final class Command {
* @param args Command-line options.
*/
public static void main(final String[] args) {
- MonolineFormatter.install();
+ /*
+ * The logging configuration is given by the "conf/logging.properties"
file in the Apache SIS
+ * installation directory. By default, that configuration file
contains the following line:
+ *
+ * java.util.logging.ConsoleHandler.formatter =
org.apache.sis.util.logging.MonolineFormatter
+ *
+ * However this configuration is silently ignored by LogManager at JVM
startup time, probably
+ * because the Apache SIS class is not on the system classpath. So we
check again for this
+ * configuration line here, and manually install our log formatter
only if the above-cited
+ * line is present.
+ */
+ final LogManager manager = LogManager.getLogManager();
+ if
(MonolineFormatter.class.getName().equals(manager.getProperty(ConsoleHandler.class.getName()
+ ".formatter"))) {
+ MonolineFormatter.install();
+ }
+ /*
+ * Now run the command.
+ */
final Command c;
try {
c = new Command(args);