net.larsan.urd.service.log
Class Service

java.lang.Object
  |
  +--net.larsan.urd.service.log.Service
All Implemented Interfaces:
Initializable, Service, Startable

public class Service
extends java.lang.Object
implements Service, Initializable, Startable

Urd log service. This service is very simple and uses a print writer to print log messages to a flat file.

The service requires a folder to write logs to. This folder should be specified in an initiation parameter called dir:

   <param name="dir" value="c:\\norna\\logs" >

The log can be filtered on log message types and levels. The following levels are accepted:

   LOWEST
   LOWER
   LOW
   NEUTRAL
   HIGH
   HIGHER
   HIGHEST
 
Levels are set with the init parameter 'logLevel' and indicates the lowest severity level to let through. For example:

   <param name="logLevel" value="LOW" >

Indicates that only log records of severity 'LOW' or higher are logged. ('LOWEST' and 'LOWER' are discared). A special token '*' logs all levels, which is default.

The accepted records types are given using a coma separated list as values to a 'logTypes' parameter. For example:

   <param name="logTypes" value="ERROR, DEBUG" >

Indicates that only records of type 'ERROR' and 'DEBUG' is logged. A special token '*' logs all types, which is default.

The log file can roll over on file size and/or time. Time formats in the initiation file are used like this: 'amounttoken' where token might be one of the following:

      ms  = milliseconds
      s   = seconds
      m   = minutes
      h   = hours
      d   = days
 
So a rollover time of '7d' would rollover once a week. The same format ('amounttoken') goes for size as well, where the tokens are:
      b   = bytes
      kb  = kilobyte
      m   = megabyte
      g   = gigabyte
 
None of the tokens - size or time - are case sensitive.

The parameter names for the rollover are 'maxFileSize' and 'maxFileAge'. And ordinary log configiration would be:

   <param name="maxFileSize" value="1M" >    <param name="maxFileAge" value="7d" >

Which would indicate that the log file should be max 1 meg in size or max one week old before triggering a rollover and a new file.

The max size parameter handles float values, so '1.5M' would be one and a half megabyte.

Version:
Alpha-0.1 / 2002-10-06 21:37
Author:
Lars J. Nilsson

Constructor Summary
Service()
           
 
Method Summary
 void destroy()
          Destroy this service.
 ServiceHandle getServiceHandle()
          Get a reference to the ServiceHandle interface for this service.
 SoftwareInfo getServiceInfo()
          Get service information.
 void init(InitParameters param)
          Initialize module.
 void setStatusCallback(StatusCallback callback)
          Set the status callback this service should use to signal status changes to the framework.
 void start()
          Start execution of this service.
 void stop()
          End execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Service

public Service()
Method Detail

setStatusCallback

public void setStatusCallback(StatusCallback callback)
Description copied from interface: Service
Set the status callback this service should use to signal status changes to the framework. It is vital that the callback received by this method is used since a service is not available to the rest of the framework until it reports its status as ready.

Specified by:
setStatusCallback in interface Service
Parameters:
callback - Status callback handle

getServiceInfo

public SoftwareInfo getServiceInfo()
Description copied from interface: Service
Get service information. This method must never return null. This method is duplicated in the ServiceHandle interface.

Specified by:
getServiceInfo in interface Service
Returns:
A SoftwareInfo object, must never return null

getServiceHandle

public ServiceHandle getServiceHandle()
Description copied from interface: Service
Get a reference to the ServiceHandle interface for this service. The service handle is the public contract used by other services. This method is guarrantied by the framework never to be called unless the service returns its status as being ready.

Specified by:
getServiceHandle in interface Service
Returns:
A Service handle object, may return null if the service status is not ready

init

public void init(InitParameters param)
          throws UnavailableException
Description copied from interface: Initializable
Initialize module. The parameters passed in to this methods are thread safe and most probably immutable and defensivly copied.

Specified by:
init in interface Initializable
Parameters:
param - Initialization parameters
Throws:
UnavailableException - If initialization failed

destroy

public void destroy()
Description copied from interface: Initializable
Destroy this service. This is guarrantied to be the last method call by the framework on the service.

Specified by:
destroy in interface Initializable

start

public void start()
Description copied from interface: Startable
Start execution of this service. This method is called only if the Service is in a LOADED / INITIALIZED or STOPPED status. This method indicates that the framework is ready to run the service. As a concequence of this call a server should proceed to READY status.

Specified by:
start in interface Startable

stop

public void stop()
Description copied from interface: Startable
End execution. This method should be performed without any overhead on excution time. Should a server need time to do cleanup it should implement the ShutdownListener interface to signal to the framework that it wishes to be informed about future stop events in advance. This method is guarrantied to be followed by either a call to Startable.start(), unload or Initializable.destroy().

Specified by:
stop in interface Startable