org.zkoss.util.logging
Class LogService

java.lang.Object
  extended by org.zkoss.util.logging.LogService

public class LogService
extends java.lang.Object

The log service which is used to monitor i3-log.conf. To initialize it, invoke init(java.lang.String, java.lang.Class). Note: Log could work without LogService.

Design consideration: the configure and configureAndWatch methods could be declared as static, but we don't. Reason: easilier to extend (also the performance gained by the static method is neglectable comparing its complexity).

Implementation Note: LogService cannot be a component (because ComponentManager depedns on iDom, which depends on log). Thus, we use Singleton instead.

Author:
tomyeh

Nested Class Summary
 class LogService.WatchdogCallback
           
 
Field Summary
protected  java.lang.String _root
          The name of the root logger that this logging service is monitoring.
 
Constructor Summary
LogService(java.lang.String root)
          Constructor.
 
Method Summary
 void configure(java.io.File file)
          Configures based the properties stored in a file.
 void configure(java.util.Properties props)
          Configures based the properties.
 void configure(java.lang.String filename)
          Configures based the properties stored in a file.
 FileWatchdog configureAndWatch(java.io.File file, long delay)
          Periodically checks whether a file is modified, and configures based the properties stored in the file, if any modifications.
static LogService init(java.lang.String rootnm, java.lang.Class cls)
          Initializes the logging service.
static boolean isInited(java.lang.String rootnm)
          Returns whether the logging service is started, i.e., whether init(java.lang.String, java.lang.Class) is invoked.
 void stop()
          Stops the service.
static void stop(java.lang.String rootnm)
          Stops the logging service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_root

protected final java.lang.String _root
The name of the root logger that this logging service is monitoring. Note: we cannot use Logger because Tomcat has one root per Web app

Constructor Detail

LogService

public LogService(java.lang.String root)
Constructor. Don't call this method directly. Rather, use init(java.lang.String, java.lang.Class) to start the service.

Method Detail

isInited

public static final boolean isInited(java.lang.String rootnm)
Returns whether the logging service is started, i.e., whether init(java.lang.String, java.lang.Class) is invoked.


init

public static final LogService init(java.lang.String rootnm,
                                    java.lang.Class cls)
Initializes the logging service. If the log service already started, an error message is logged.

Note: it also enables the hierarchy support of loggers by calling Log.setHierarchy(boolean) with true.

Parameters:
rootnm - the name of the root logger. The logging service registered handlers at the specified logger.
cls - the implementation to start. If null, LogService is used.

stop

public static final void stop(java.lang.String rootnm)
Stops the logging service


stop

public void stop()
Stops the service. You rarely need to do so. This service monitors whether any preference is changed, and automatically reflects the new changes.


configure

public final void configure(java.util.Properties props)
Configures based the properties.

The key is a logger name and the value is the level. A special level, INHERIT or NULL, to denote resetting the level to be the same as the logger's parent.

Parameters:
props - the properties

configure

public final void configure(java.io.File file)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Configures based the properties stored in a file.

The key is a logger name and the value is the level.

Parameters:
file - the file
Throws:
java.io.FileNotFoundException
java.io.IOException

configure

public final void configure(java.lang.String filename)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Configures based the properties stored in a file.

The key is a logger name and the value is the level.

Parameters:
filename - the filename
Throws:
java.io.FileNotFoundException
java.io.IOException

configureAndWatch

public final FileWatchdog configureAndWatch(java.io.File file,
                                            long delay)
Periodically checks whether a file is modified, and configures based the properties stored in the file, if any modifications.

The key is a logger name and the value is the level.

Parameters:
file - the file
delay - the delay in milliseconds to wait between each check.


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo