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 zk-log.conf. To initialize it, invoke init(java.lang.String, java.lang.Class). Note: Log could work without LogService.

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

Author:
tomyeh

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.
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. Notice the heirachy is always disabled if a library property called org.zkoss.util.logging.hierarchy.disabled is set to 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


Copyright © 2011. All Rights Reserved.