Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

The following information is valid for IzPack versions >= 5.0.11, where the logging behavior has been consolidated.

Introduction

IzPack installers use Java Logging for logging any information. If you want to customize it you should be familar with it, otherwise there is a good description of its principles in Oracle's Java Logging Overview.

Unless overridden on the command line, an installer overrides the JVM log settings and logs to the console in a special format, depending on the log level. The log level depends on whether you set IzPack to debug mode by adding the -DDEBUG=true JVM option. If the installer runs in debug mode the Java Logging level for the installer implementation (package com.izforge.izpack) is set to FINE by default globally, otherwise INFO.

If the log level results in INFO the log output appears simplified with one line per log entry, for the debug mode there will be shown an enhanced output with class and method names and a timestamp.

You can override Java Logging handler, formatting and log levels for each Java package hierarchy you add to a configuration file, which can be given by the JVM command line option -Djava.util.logging.config.file=<path>.

Alternatively, there might be used am own custom implementation given as parameter -Djava.util.logging.config.class=<classname>, which initializes the installer logging in its default constructor. See the LogManager API Specification for more information.

Here is what an example installer logs to the console when without custom logging:

> /usr/java/jdk1.8.0_112/jre/bin/java -jar installer.jar
Logging initialized
Commandline arguments:  
Detected platform: suse_linux,version=4.8.13-1-default,arch=x64,symbolicName=null,javaVersion=1.8.0_112

If you wish to add debug information to the log of the IzPack installer implementation you can add the -DDEBUG=true JVM option, which will result in a very messy output with information for installer developers (shortened):

> /usr/java/jdk1.8.0_112/jre/bin/java -DDEBUG=true -jar installer.jar
java.util.logging.LogManager$RootLogger log
INFO: Logging initialized
com.izforge.izpack.installer.bootstrap.Installer start
INFO: Commandline arguments:  
com.izforge.izpack.core.resource.DefaultLocales getMessagesStream
FINE: Locale has no langpack for code:  
com.izforge.izpack.core.container.PlatformProvider provide
INFO: Detected platform: suse_linux,version=4.8.13-1-default,arch=x64,symbolicName=null,javaVersion=1.8.0_112
com.izforge.izpack.core.data.DefaultVariables set
FINE: Dynamic variable 'APP_NAME' set to 'My Great Application'
...

Example of log customization using a configuration file

The example here is very simple, just for the purpose to show how the installer handles logging customization.

To activate the contents of a configuration file add its path to the command line as value of the system property java.util.logging.config.file JVM parameter, for example like this:

-Djava.util.logging.config.file=/home/rkrell/logging.properties

IzPack uses the following built-in configuration;

Example: Simulating IzPack built-in logging
# Global logging properties.
# ------------------------------------------
# The set of handlers to be loaded upon startup.
# Comma-separated list of class names.
com.izforge.izpack.util.handlers = com.izforge.izpack.util.LogHandler

com.izforge.izpack.util.LogHandler.formatter = com.izforge.izpack.util.LogFormatter

# The IzPack LogHandler implementation overrides the log level automatically depending on whether we are in debug mode (JVM option -DDEBUG=true)

If you want to use the default JVM console log handler and formatter instead of the IzPack built-in facilities you might use this configuration file:

Example: logging.properties
# Global logging properties.
# ------------------------------------------
# The set of handlers to be loaded upon startup.
# Comma-separated list of class names.
# (? LogManager docs say no comma here, but JDK example has comma.)
handlers = java.util.logging.ConsoleHandler

# Default global logging level.
# Loggers and Handlers may override this level
.level = FINE

# The Java ConsoleHandler implementation has its own logging level setting
java.util.logging.ConsoleHandler.level = FINE

You might for example mix both configuration above:

Example: Mixing Java and IzPack logging configuration
# Global logging properties.
# ------------------------------------------
# The set of handlers to be loaded upon startup.
# Comma-separated list of class names.
# (? LogManager docs say no comma here, but JDK example has comma.)
handlers = java.util.logging.ConsoleHandler

java.util.logging.ConsoleHandler.formatter = com.izforge.izpack.util.LogFormatter

# Default global logging level.
.level=FINE

You can also log to files, sockets and other resources, see the appropriate handler implementation and their dedicated configuration for more details.

There might be used own custom handlers for writing the log to a database or to a log collector web service, no limits here.

  • No labels