Top Description Inners Fields Constructors Methods
sun.util.logging

public Class PlatformLogger

extends Object
Class Inheritance
Imports
java.lang.ref.WeakReference, java.util.Arrays, .HashMap, .Map, .ResourceBundle, java.util.function.Supplier, jdk.internal.logger.LazyLoggers, .LoggerWrapper

Platform logger provides an API for the JRE components to log messages. This enables the runtime components to eliminate the static dependency of the logging facility and also defers the java.util.logging initialization until it is enabled. In addition, the PlatformLogger API can be used if the logging module does not exist. If the logging facility is not enabled, the platform loggers will output log messages per the default logging configuration (see below). In this implementation, it does not log the stack frame information issuing the log message. When the logging facility is enabled (at startup or runtime), the backend logger will be created for each platform logger and all log messages will be forwarded to the Logger to handle. The PlatformLogger uses an underlying PlatformLogger.Bridge instance obtained by calling PlatformLogger.Bridge.convert( jdk.internal.logger.LazyLoggers#getLazyLogger(name, PlatformLogger.class)). Logging facility is "enabled" when one of the following conditions is met: 1) ServiceLoader.load(LoggerFinder.class, ClassLoader.getSystemClassLoader()).iterator().hasNext(). 2) ServiceLoader.loadInstalled(jdk.internal.logger.DefaultLoggerFinder).iterator().hasNext(), and 2.1) a system property "java.util.logging.config.class" or "java.util.logging.config.file" is set or 2.2) java.util.logging.LogManager or java.util.logging.Logger is referenced that will trigger the logging initialization. Default logging configuration: No LoggerFinder service implementation declared global logging level = INFO handlers = java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level = INFO java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter Limitation: <JAVA_HOME>/conf/logging.properties is the system-wide logging configuration defined in the specification and read in the default case to configure any java.util.logging.Logger instances. Platform loggers will not detect if <JAVA_HOME>/conf/logging.properties is modified. In other words, unless the java.util.logging API is used at runtime or the logging system properties is set, the platform loggers will use the default setting described above. The platform loggers are designed for JDK developers use and this limitation can be workaround with setting -Djava.util.logging.config.file system property.
Calling PlatformLogger.setLevel will not work when there is a custom LoggerFinder installed - and as a consequence setLevel is now deprecated.
Since
1.7

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
PlatformLogger.Bridge

The PlatformLogger.Bridge interface is implemented by the System.Logger objects returned by our default JUL provider - so that JRE classes using PlatformLogger see no difference when JUL is the actual backend.

public static interface
PlatformLogger.ConfigurableBridge

The PlatformLogger.ConfigurableBridge interface is used to implement the deprecated PlatformLogger#setLevel method.

public static enum
PlatformLogger.Level

PlatformLogger logging levels.

Field Summary

Modifier and TypeField and Description
private final PlatformLogger.Bridge
private static final Map<String, WeakReference<PlatformLogger>>
private static final PlatformLogger.Level[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
config(String
the message
msg
)

Logs a CONFIG message.

public void
public void
config(String msg, Object... params)

public void
fine(String
the message
msg
)

Logs a FINE message.

public void
public void
fine(String msg, Object... params)

public void
finer(String
the message
msg
)

Logs a FINER message.

public void
public void
finer(String msg, Object... params)

public void
finest(String
the message
msg
)

Logs a FINEST message.

public void
public void
finest(String msg, Object... params)

public static synchronized PlatformLogger

Returns:

a PlatformLogger
getLogger
(String
the name of the logger
name
)

Returns a PlatformLogger of a given name.

public String

Returns:

the name of the platform logger.
getName
()

Gets the name for this platform logger.

public void
info(String
the message
msg
)

Logs an INFO message.

public void
public void
info(String msg, Object... params)

public boolean

Returns:

whether the logger is turned off.
isEnabled
()

A convenience method to test if the logger is turned off.

public boolean

Returns:

whether a message of that level would be logged
isLoggable
(PlatformLogger.Level
the level
level
)

Returns true if a message of the given level would actually be logged by this logger.

public PlatformLogger.Level

Returns:

this PlatformLogger's level
level
()

Get the log level that has been specified for this PlatformLogger.

public void
setLevel(PlatformLogger.Level
the new value for the log level (may be null)
newLevel
)
Deprecated Platform Loggers should not be configured programmatically.

Set the log level specifying which message levels will be logged by this logger.

public void
severe(String
the message
msg
)

Logs a SEVERE message.

public void
public void
severe(String msg, Object... params)

public static PlatformLogger.Level
public void
warning(String
the message
msg
)

Logs a WARNING message.

public void
public void
warning(String msg, Object... params)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerProxyback to summary
private final PlatformLogger.Bridge loggerProxy
loggersback to summary
private static final Map<String, WeakReference<PlatformLogger>> loggers
spi2platformLevelMappingback to summary
private static final PlatformLogger.Level[] spi2platformLevelMapping

Constructor Detail

PlatformLoggerback to summary
private PlatformLogger(PlatformLogger.Bridge loggerProxy)

Method Detail

configback to summary
public void config(String msg)

Logs a CONFIG message.

Parameters
msg:String

the message

configback to summary
public void config(String msg, Throwable t)
configback to summary
public void config(String msg, Object... params)
fineback to summary
public void fine(String msg)

Logs a FINE message.

Parameters
msg:String

the message

fineback to summary
public void fine(String msg, Throwable t)
fineback to summary
public void fine(String msg, Object... params)
finerback to summary
public void finer(String msg)

Logs a FINER message.

Parameters
msg:String

the message

finerback to summary
public void finer(String msg, Throwable t)
finerback to summary
public void finer(String msg, Object... params)
finestback to summary
public void finest(String msg)

Logs a FINEST message.

Parameters
msg:String

the message

finestback to summary
public void finest(String msg, Throwable t)
finestback to summary
public void finest(String msg, Object... params)
getLoggerback to summary
public static synchronized PlatformLogger getLogger(String name)

Returns a PlatformLogger of a given name.

Parameters
name:String

the name of the logger

Returns:PlatformLogger

a PlatformLogger

getNameback to summary
public String getName()

Gets the name for this platform logger.

Returns:String

the name of the platform logger.

infoback to summary
public void info(String msg)

Logs an INFO message.

Parameters
msg:String

the message

infoback to summary
public void info(String msg, Throwable t)
infoback to summary
public void info(String msg, Object... params)
isEnabledback to summary
public boolean isEnabled()

A convenience method to test if the logger is turned off. (i.e. its level is OFF).

Returns:boolean

whether the logger is turned off.

isLoggableback to summary
public boolean isLoggable(PlatformLogger.Level level)

Returns true if a message of the given level would actually be logged by this logger.

Parameters
level:PlatformLogger.Level

the level

Returns:boolean

whether a message of that level would be logged

levelback to summary
public PlatformLogger.Level level()

Get the log level that has been specified for this PlatformLogger. The result may be null, which means that this logger's effective level will be inherited from its parent.

Returns:PlatformLogger.Level

this PlatformLogger's level

setLevelback to summary
public void setLevel(PlatformLogger.Level newLevel)

Deprecated

Platform Loggers should not be configured programmatically. This method will not work if a custom java.lang.System.LoggerFinder is installed.

Set the log level specifying which message levels will be logged by this logger. Message levels lower than this value will be discarded. The level value Level#OFF can be used to turn off logging.

If the new level is null, it means that this node should inherit its level from its nearest ancestor with a specific (non-null) level value.

Parameters
newLevel:PlatformLogger.Level

the new value for the log level (may be null)

Annotations
@Deprecated
severeback to summary
public void severe(String msg)

Logs a SEVERE message.

Parameters
msg:String

the message

severeback to summary
public void severe(String msg, Throwable t)
severeback to summary
public void severe(String msg, Object... params)
toPlatformLevelback to summary
public static PlatformLogger.Level toPlatformLevel(System.Logger.Level level)
warningback to summary
public void warning(String msg)

Logs a WARNING message.

Parameters
msg:String

the message

warningback to summary
public void warning(String msg, Throwable t)
warningback to summary
public void warning(String msg, Object... params)
sun.util.logging back to summary

public Interface PlatformLogger.Bridge

Known Direct Implementers
jdk.internal.logger.AbstractLoggerWrapper, jdk.internal.logger.BootstrapLogger, jdk.internal.logger.SimpleConsoleLogger

The PlatformLogger.Bridge interface is implemented by the System.Logger objects returned by our default JUL provider - so that JRE classes using PlatformLogger see no difference when JUL is the actual backend. PlatformLogger is now only a thin adaptation layer over the same loggers than returned by java.lang.System.getLogger(String name). The recommendation for JRE classes going forward is to use java.lang.System.getLogger(String name), which will use Lazy Loggers when possible and necessary.

Method Summary

Modifier and TypeMethod and Description
public static PlatformLogger.Bridge
public String

Returns:

the name of the platform logger.
getName
()

Gets the name for this platform logger.

public boolean
public boolean

Returns:

whether a message of that level would be logged
isLoggable
(PlatformLogger.Level
the level
level
)

Returns true if a message of the given level would actually be logged by this logger.

public void
public void
log(PlatformLogger.Level level, String msg, Throwable thrown)

public void
log(PlatformLogger.Level level, String msg, Object... params)

public void
log(PlatformLogger.Level level, Supplier<String> msgSupplier)

public void
log(PlatformLogger.Level level, Throwable thrown, Supplier<String> msgSupplier)

public void
logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, String msg)

public void
logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, Supplier<String> msgSupplier)

public void
logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, String msg, Object... params)

public void
logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, String msg, Throwable thrown)

public void
logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, Throwable thrown, Supplier<String> msgSupplier)

public void
logrb(PlatformLogger.Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Object... params)

public void
logrb(PlatformLogger.Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Throwable thrown)

public void
logrb(PlatformLogger.Level level, ResourceBundle bundle, String msg, Object... params)

public void

Method Detail

convertback to summary
public static PlatformLogger.Bridge convert(System.Logger logger)
getNameback to summary
public String getName()

Gets the name for this platform logger.

Returns:String

the name of the platform logger.

isEnabledback to summary
public boolean isEnabled()
isLoggableback to summary
public boolean isLoggable(PlatformLogger.Level level)

Returns true if a message of the given level would actually be logged by this logger.

Parameters
level:PlatformLogger.Level

the level

Returns:boolean

whether a message of that level would be logged

logback to summary
public void log(PlatformLogger.Level level, String msg)
logback to summary
public void log(PlatformLogger.Level level, String msg, Throwable thrown)
logback to summary
public void log(PlatformLogger.Level level, String msg, Object... params)
logback to summary
public void log(PlatformLogger.Level level, Supplier<String> msgSupplier)
logback to summary
public void log(PlatformLogger.Level level, Throwable thrown, Supplier<String> msgSupplier)
logpback to summary
public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, String msg)
logpback to summary
public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, Supplier<String> msgSupplier)
logpback to summary
public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, String msg, Object... params)
logpback to summary
public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, String msg, Throwable thrown)
logpback to summary
public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, Throwable thrown, Supplier<String> msgSupplier)
logrbback to summary
public void logrb(PlatformLogger.Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Object... params)
logrbback to summary
public void logrb(PlatformLogger.Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Throwable thrown)
logrbback to summary
public void logrb(PlatformLogger.Level level, ResourceBundle bundle, String msg, Object... params)
logrbback to summary
public void logrb(PlatformLogger.Level level, ResourceBundle bundle, String msg, Throwable thrown)
sun.util.logging back to summary

public Interface PlatformLogger.ConfigurableBridge

Known Direct Implementers
jdk.internal.logger.AbstractLoggerWrapper, jdk.internal.logger.BootstrapLogger, jdk.internal.logger.SimpleConsoleLogger

The PlatformLogger.ConfigurableBridge interface is used to implement the deprecated PlatformLogger#setLevel method. PlatformLogger is now only a thin adaptation layer over the same loggers than returned by java.lang.System.getLogger(String name). The recommendation for JRE classes going forward is to use java.lang.System.getLogger(String name), which will use Lazy Loggers when possible and necessary.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class

Method Summary

Modifier and TypeMethod and Description
public default PlatformLogger.ConfigurableBridge.LoggerConfiguration
public static PlatformLogger.ConfigurableBridge.LoggerConfiguration

Method Detail

getLoggerConfigurationback to summary
public default PlatformLogger.ConfigurableBridge.LoggerConfiguration getLoggerConfiguration()
getLoggerConfigurationback to summary
public static PlatformLogger.ConfigurableBridge.LoggerConfiguration getLoggerConfiguration(PlatformLogger.Bridge logger)
sun.util.logging back to summary

public abstract Class PlatformLogger.ConfigurableBridge.LoggerConfiguration

extends Object
Class Inheritance
  • java.lang.Object
  • sun.util.logging.PlatformLogger.ConfigurableBridge.LoggerConfiguration
Known Direct Subclasses
jdk.internal.logger.SimpleConsoleLogger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract PlatformLogger.Level
public abstract void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

LoggerConfigurationback to summary
public LoggerConfiguration()

Method Detail

getPlatformLevelback to summary
public abstract PlatformLogger.Level getPlatformLevel()
setPlatformLevelback to summary
public abstract void setPlatformLevel(PlatformLogger.Level level)
sun.util.logging back to summary

public final Enum PlatformLogger.Level

extends Enum<PlatformLogger.Level>
Class Inheritance

PlatformLogger logging levels.

Field Summary

Modifier and TypeField and Description
public static final PlatformLogger.Level
public static final PlatformLogger.Level
public static final PlatformLogger.Level
public static final PlatformLogger.Level
public static final PlatformLogger.Level
public static final PlatformLogger.Level
private static final int[]
public static final PlatformLogger.Level
public static final PlatformLogger.Level
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
pack-priv final System.Logger.Level
public static final PlatformLogger.Level

Constructor Summary

AccessConstructor and Description
private
Level(System.Logger.Level systemLevel)

Method Summary

Modifier and TypeMethod and Description
public int
public System.Logger.Level
public static PlatformLogger.Level
public static PlatformLogger.Level

Returns:

The effective logger level, which is the nearest Level value whose severity is greater or equal to the given level. For level > SEVERE (OFF excluded), return SEVERE.
valueOf
(int
The severity of the messages that should be logged with a logger set to the returned level.
level
)

Maps a severity value to an effective logger level.

public static PlatformLogger.Level[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALLback to summary
public static final PlatformLogger.Level ALL
CONFIGback to summary
public static final PlatformLogger.Level CONFIG
FINEback to summary
public static final PlatformLogger.Level FINE
FINERback to summary
public static final PlatformLogger.Level FINER
FINESTback to summary
public static final PlatformLogger.Level FINEST
INFOback to summary
public static final PlatformLogger.Level INFO
LEVEL_VALUESback to summary
private static final int[] LEVEL_VALUES
OFFback to summary
public static final PlatformLogger.Level OFF
SEVEREback to summary
public static final PlatformLogger.Level SEVERE
SEVERITY_ALLback to summary
private static final int SEVERITY_ALL
SEVERITY_CONFIGback to summary
private static final int SEVERITY_CONFIG
SEVERITY_FINEback to summary
private static final int SEVERITY_FINE
SEVERITY_FINERback to summary
private static final int SEVERITY_FINER
SEVERITY_FINESTback to summary
private static final int SEVERITY_FINEST
SEVERITY_INFOback to summary
private static final int SEVERITY_INFO
SEVERITY_OFFback to summary
private static final int SEVERITY_OFF
SEVERITY_SEVEREback to summary
private static final int SEVERITY_SEVERE
SEVERITY_WARNINGback to summary
private static final int SEVERITY_WARNING
systemLevelback to summary
pack-priv final System.Logger.Level systemLevel
WARNINGback to summary
public static final PlatformLogger.Level WARNING

Constructor Detail

Levelback to summary
private Level(System.Logger.Level systemLevel)

Method Detail

intValueback to summary
public int intValue()
systemLevelback to summary
public System.Logger.Level systemLevel()
valueOfback to summary
public static PlatformLogger.Level valueOf(String name)
valueOfback to summary
public static PlatformLogger.Level valueOf(int level)

Maps a severity value to an effective logger level.

Parameters
level:int

The severity of the messages that should be logged with a logger set to the returned level.

Returns:PlatformLogger.Level

The effective logger level, which is the nearest Level value whose severity is greater or equal to the given level. For level > SEVERE (OFF excluded), return SEVERE.

valuesback to summary
public static PlatformLogger.Level[] values()