util
Class PropertySyslog

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertySyslog
All Implemented Interfaces:
Cloneable, Remote, Initializable, PropertyBearing, SyslogAdjusting
Direct Known Subclasses:
LoggerTest

public class PropertySyslog
extends PropertyContainer
implements SyslogAdjusting

Allows access to the system-logging facilities. Any class with a main method that wants to implement the PropertyBearing interface should rather extend this class then the PropertyContainer.
A note on changing default behavior of the Syslog-class, which is interesting if you use Syslog without loading any property syslog into your java VM:

Setting system properties on the command line is done with the -D option on calling java, e.g. java -DSyslog.level=DEBUG .

On class-load, a default system-logger configuration is passed to the Syslog class. If the properties of this class define system-wide loggers, they are added to the system logger class, if no logger of the given name is present. The keys ruling the definition of the loggers mean:

Additionally, the following keys may be specified for all loggers. The key used is one of the four logger keys augmented with the key ending. This class additionally implements the remote interface SyslogAdjusting. Accessing any instance of a property syslog class through this interface changes all loggers in the VM this object resides in.
Implementation note: To successfully access the rmi-methods, subclasses of this class must somehow export themselves to the registry. This is not done in the construction phase of this class.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyContainer
PropertyContainer.URLResource
 
Field Summary
static String APPEND
          The key linked to file-append.
static String BCC
          The key to the mail receivers.
static String CC
          The key to the mail receivers.
static String CHANNELSHOW
          The key extension to the class-should-show of the logger.
static String CHANNELWIDTH
          The key extension to the class-width of the logger.
static String CLASSWIDTH
          The key extension to the class-width of the logger.
static String DATECACHE
          The key extension to the date cache of the logger.
static String DATEFORMAT
          The key extension to the date formatter of the logger.
private static String DEFEXT
          Default file-extension for time roll-over loggers.
private static Map<String,String> DEFLOG
          Default properties to use for the syslog.
private static String DEFPRINTWRITER
          Default print writer to use for the syslog.
private static String DEFPRINTWRITERCACHE
          Default print writer date cache time.
private static String DEFPRINTWRITERFORMAT
          Default print writer date format.
private static String DEFPRINTWRITERLEVEL
          Default print writer logger level.
private static String DEFPRINTWRITERNAME
          Default print writer logger name.
private static int DEFROLL
          Default roll-over time.
static String EXTENSION
          The key to the file extension of the time roll-over log.
static String FACILITY
          The key linked to the logger-server's facility.
static String FLUSH
          The key linked to auto-flush.
static String HOSTSHOW
          The key extension to the class-should-show of the logger.
static String HOSTWIDTH
          The key extension to the class-width of the logger.
static String KEY_DATAGRAMLOG
          The key linked to a datagram log.
static String KEY_FILELOG
          The key linked to a file log.
static String KEY_MAILLOG
          The key linked to a mail log.
static String KEY_PRINTWRITERLOG
          The key linked to a print writer log.
static String KEY_REMOTELOG
          A key, if present construct a RemoteLogServer.
static String KEY_TIMEROLLOVERLOG
          The key linked to a time roll over log.
static String LEVEL
          The key extension to the level of the logger (0-16).
static String NAME
          The key extension to the name of the logger.
static String NAMEFORMAT
          The key to the name format of the time roll-over log.
static String PORT
          The key linked to the logger-server's port.
static String ROLL
          The key to the roll-over intervall of the time roll-over log.
static String THREADSHOW
          The key extension to the class-should-show of the logger.
static String THREADWIDTH
          The key extension to the class-width of the logger.
static String TO
          The key to the mail receivers.
 
Fields inherited from class util.PropertyContainer
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_NOINITONCREATE, KEY_RESOURCEBUNDLES
 
Fields inherited from interface util.PropertyBearing
CONFIG, KEY_CLASS, KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
PropertySyslog(Map<String,String> props)
          Constructs a new property syslog.
 
Method Summary
private static com.protomatter.syslog.Syslogger addAllLoggerProperties(Map<String,String> log, String basekey, com.protomatter.syslog.BasicLogger logger)
          Adds a syslogger to the list of sysloggers.
 boolean addLogger(Map<String,String> logprop)
          Adds a syslogger.
static boolean addSysloggers(Map<String,String> props)
          Scans the properties and adds static sysloggers.
static void addThreadLogging()
          Adds thread logging if possible.
static void defaultLogging()
          Clears all sysloggers.
 void disableLogging()
          Disables all loggings.
 void enableLogging()
          (Re-)Enables all loggings.
 List<String> getAllLoggers()
          Returns a list of all logger names.
private static String getLoggerName(Map log, String key)
          Gets the logger name.
 com.protomatter.syslog.LogPolicy getLoggerPolicy(String name)
          Returns the syslog-logger policy with the specified name.
 void removeAllLoggers()
          Removes all loggers.
 boolean removeLogger(String name)
          Removes a logger.
static List<com.protomatter.syslog.Syslogger> scanProperties(Map<String,String> log)
          Scans the properties for syslog entries.
static void setAllLogLevel(String mask)
          Sets the log level for all loggers.
 boolean setLoggerPolicy(String name, com.protomatter.syslog.LogPolicy newpolicy)
          Sets the logger policy using the name of the logger.
 
Methods inherited from class util.PropertyContainer
clone, createFrom, createFrom, createFrom, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getLocalClassLoader, getLocalized, getLocalized, getLocalizedString, getLocalizedString, getProperties, getPropertiesToKey, getPropertiesToKey, getProperty, getResource, getResourceAsStream, getResourceFromKey, getResources, has, init, isNew, keyCreate, keyCreate, parseObject, reload, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_FILELOG

public static final String KEY_FILELOG
The key linked to a file log.

See Also:
Constant Field Values

APPEND

public static final String APPEND
The key linked to file-append. Used with file loggers.

See Also:
Constant Field Values

FLUSH

public static final String FLUSH
The key linked to auto-flush. Used with file loggers.

See Also:
Constant Field Values

KEY_PRINTWRITERLOG

public static final String KEY_PRINTWRITERLOG
The key linked to a print writer log.

See Also:
Constant Field Values

KEY_MAILLOG

public static final String KEY_MAILLOG
The key linked to a mail log.

See Also:
Constant Field Values

TO

public static final String TO
The key to the mail receivers. Used only with KEY_MAILLOG.

See Also:
Constant Field Values

CC

public static final String CC
The key to the mail receivers. Used only with KEY_MAILLOG.

See Also:
Constant Field Values

BCC

public static final String BCC
The key to the mail receivers. Used only with KEY_MAILLOG.

See Also:
Constant Field Values

KEY_TIMEROLLOVERLOG

public static final String KEY_TIMEROLLOVERLOG
The key linked to a time roll over log.

See Also:
Constant Field Values

EXTENSION

public static final String EXTENSION
The key to the file extension of the time roll-over log.

See Also:
Constant Field Values

ROLL

public static final String ROLL
The key to the roll-over intervall of the time roll-over log.

See Also:
Constant Field Values

NAMEFORMAT

public static final String NAMEFORMAT
The key to the name format of the time roll-over log.

See Also:
Constant Field Values

KEY_DATAGRAMLOG

public static final String KEY_DATAGRAMLOG
The key linked to a datagram log.

See Also:
Constant Field Values

PORT

public static final String PORT
The key linked to the logger-server's port.

See Also:
Constant Field Values

FACILITY

public static final String FACILITY
The key linked to the logger-server's facility.

See Also:
Constant Field Values

KEY_REMOTELOG

public static final String KEY_REMOTELOG
A key, if present construct a RemoteLogServer.

See Also:
Constant Field Values

NAME

public static final String NAME
The key extension to the name of the logger.

See Also:
Constant Field Values

LEVEL

public static final String LEVEL
The key extension to the level of the logger (0-16).

See Also:
Constant Field Values

DATEFORMAT

public static final String DATEFORMAT
The key extension to the date formatter of the logger.

See Also:
Constant Field Values

DATECACHE

public static final String DATECACHE
The key extension to the date cache of the logger.

See Also:
Constant Field Values

CLASSWIDTH

public static final String CLASSWIDTH
The key extension to the class-width of the logger.

See Also:
Constant Field Values

CHANNELWIDTH

public static final String CHANNELWIDTH
The key extension to the class-width of the logger.

See Also:
Constant Field Values

CHANNELSHOW

public static final String CHANNELSHOW
The key extension to the class-should-show of the logger.

See Also:
Constant Field Values

THREADWIDTH

public static final String THREADWIDTH
The key extension to the class-width of the logger.

See Also:
Constant Field Values

THREADSHOW

public static final String THREADSHOW
The key extension to the class-should-show of the logger.

See Also:
Constant Field Values

HOSTWIDTH

public static final String HOSTWIDTH
The key extension to the class-width of the logger.

See Also:
Constant Field Values

HOSTSHOW

public static final String HOSTSHOW
The key extension to the class-should-show of the logger.

See Also:
Constant Field Values

DEFLOG

private static final Map<String,String> DEFLOG
Default properties to use for the syslog.


DEFPRINTWRITER

private static final String DEFPRINTWRITER
Default print writer to use for the syslog.

See Also:
Constant Field Values

DEFPRINTWRITERNAME

private static final String DEFPRINTWRITERNAME
Default print writer logger name.

See Also:
Constant Field Values

DEFPRINTWRITERLEVEL

private static final String DEFPRINTWRITERLEVEL
Default print writer logger level.

See Also:
Constant Field Values

DEFPRINTWRITERFORMAT

private static final String DEFPRINTWRITERFORMAT
Default print writer date format.

See Also:
Constant Field Values

DEFPRINTWRITERCACHE

private static final String DEFPRINTWRITERCACHE
Default print writer date cache time.

See Also:
Constant Field Values

DEFROLL

private static final int DEFROLL
Default roll-over time.


DEFEXT

private static final String DEFEXT
Default file-extension for time roll-over loggers.

See Also:
Constant Field Values
Constructor Detail

PropertySyslog

public PropertySyslog(Map<String,String> props)
Constructs a new property syslog. If loggers are specified in the properties argument, they are added to the syslog. The method is protected to avoid improper use.

Method Detail

defaultLogging

public static void defaultLogging()
Clears all sysloggers. Use the default properties for constructing basic syslog capabilities. Constructs the static reference to the shutdown cleaner job.


addSysloggers

public static boolean addSysloggers(Map<String,String> props)
Scans the properties and adds static sysloggers. For classes that want to define loggers in their properties, but do not want to extend this class.

Returns:
True, if at least one logger was added.

getLoggerPolicy

public com.protomatter.syslog.LogPolicy getLoggerPolicy(String name)
                                                 throws RemoteException
Returns the syslog-logger policy with the specified name.

Specified by:
getLoggerPolicy in interface SyslogAdjusting
Throws:
RemoteException

setLoggerPolicy

public boolean setLoggerPolicy(String name,
                               com.protomatter.syslog.LogPolicy newpolicy)
                        throws RemoteException
Sets the logger policy using the name of the logger.

Specified by:
setLoggerPolicy in interface SyslogAdjusting
Throws:
RemoteException

getAllLoggers

public List<String> getAllLoggers()
                           throws RemoteException
Returns a list of all logger names.

Specified by:
getAllLoggers in interface SyslogAdjusting
Throws:
RemoteException

removeLogger

public boolean removeLogger(String name)
                     throws RemoteException
Removes a logger. If more than one logger of the given name exists, only the first reference is removed

Specified by:
removeLogger in interface SyslogAdjusting
Returns:
True, if a logger was found and successfully removed.
Throws:
RemoteException

removeAllLoggers

public void removeAllLoggers()
                      throws RemoteException
Removes all loggers.

Specified by:
removeAllLoggers in interface SyslogAdjusting
Throws:
RemoteException

addLogger

public boolean addLogger(Map<String,String> logprop)
                  throws RemoteException
Adds a syslogger. This method will only succeed if no logger with the specified name is already present.

Specified by:
addLogger in interface SyslogAdjusting
Returns:
True, if adding the logger was successful
Throws:
RemoteException

disableLogging

public void disableLogging()
                    throws RemoteException
Disables all loggings.

Specified by:
disableLogging in interface SyslogAdjusting
Throws:
RemoteException

enableLogging

public void enableLogging()
                   throws RemoteException
(Re-)Enables all loggings.

Specified by:
enableLogging in interface SyslogAdjusting
Throws:
RemoteException

scanProperties

public static List<com.protomatter.syslog.Syslogger> scanProperties(Map<String,String> log)
Scans the properties for syslog entries. If an entry is found, a new logger is constructed and added to the list.
All mappings in the argumental map must be mappings to Strings.


getLoggerName

private static String getLoggerName(Map log,
                                    String key)
Gets the logger name. If no name is specified, it defaults to LoggerKey:LoggerKeyValue.


addThreadLogging

public static void addThreadLogging()
Adds thread logging if possible.


setAllLogLevel

public static void setAllLogLevel(String mask)
Sets the log level for all loggers.


addAllLoggerProperties

private static com.protomatter.syslog.Syslogger addAllLoggerProperties(Map<String,String> log,
                                                                       String basekey,
                                                                       com.protomatter.syslog.BasicLogger logger)
Adds a syslogger to the list of sysloggers. If a logger with the specified name is already present, nothing is done. Scans for all logger properties and sets them accordingly on the syslogger before adding the syslogger to the list of server sysloggers.