no.feide.moria.log
Class AccessLogger

java.lang.Object
  extended by no.feide.moria.log.AccessLogger
All Implemented Interfaces:
java.io.Serializable

public final class AccessLogger
extends java.lang.Object
implements java.io.Serializable

Logs system events in a strict format that may later be used for usage statistics generation. Logging is done at log4j level WARN. If the loglevel of log4j is set above this, no log-entries will be written. The format of the log-lines is the following:

 [2004-04-30 17:10:19,046] "BAD USER CREDENTIALS" "no.feide.test" "demo@feide.no" "235892791" "350215527"

 [Timestamp] "STATUS" "service principal" "userid" "incoming ticket" "outgoing ticket"
 

Version:
$Revision: 1.9 $
Author:
Bjørn Ola Smievoll <b.o@smievoll.no>
See Also:
Serialized Form

Field Summary
private static java.lang.Class ACCESS_LOGGER_CLASS
          The name of this logger.
private  org.apache.log4j.Logger logger
          Log to this logger.
 
Constructor Summary
AccessLogger()
          Default constructor.
 
Method Summary
private  java.lang.String generateLogMessage(AccessStatusType status, java.lang.String servicePrincipal, java.lang.String userId, java.lang.String incomingTicketId, java.lang.String outgoingTicketId)
          Generates log messages in the correct format.
private  org.apache.log4j.Logger getLogger()
          Returns the logger, instantiates it if not already done.
 void logService(AccessStatusType status, java.lang.String servicePrincipal, java.lang.String incomingTicketId, java.lang.String outgoingTicketId)
          Logs service-initiated access.
 void logUser(AccessStatusType status, java.lang.String servicePrincipal, java.lang.String userId, java.lang.String incomingTicketId, java.lang.String outgoingTicketId)
          Logs user-initiated access (user interaction through the web interface).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACCESS_LOGGER_CLASS

private static final java.lang.Class ACCESS_LOGGER_CLASS
The name of this logger. Same for all classes, so we can be redirect output to a common file.


logger

private transient org.apache.log4j.Logger logger
Log to this logger. Transient, so the class can be serialized.

Constructor Detail

AccessLogger

public AccessLogger()
Default constructor.

Method Detail

logUser

public void logUser(AccessStatusType status,
                    java.lang.String servicePrincipal,
                    java.lang.String userId,
                    java.lang.String incomingTicketId,
                    java.lang.String outgoingTicketId)
Logs user-initiated access (user interaction through the web interface).

Parameters:
status - Indicates the type of event.
servicePrincipal - The id of the service that is responsible for this operation.
userId - The id of the user, may be null if unknown at time of event.
incomingTicketId - The id of the ticket given with the request.
outgoingTicketId - The id of the potentially returned ticket, may be null.

logService

public void logService(AccessStatusType status,
                       java.lang.String servicePrincipal,
                       java.lang.String incomingTicketId,
                       java.lang.String outgoingTicketId)
Logs service-initiated access.

Parameters:
status - Indicates the type of event.
servicePrincipal - The id of the service that is performing the operation.
incomingTicketId - The id of the ticket given with the request.
outgoingTicketId - The id of the potentially returned ticket, may be null.

generateLogMessage

private java.lang.String generateLogMessage(AccessStatusType status,
                                            java.lang.String servicePrincipal,
                                            java.lang.String userId,
                                            java.lang.String incomingTicketId,
                                            java.lang.String outgoingTicketId)
Generates log messages in the correct format.

Parameters:
status - Indicates the type of event.
servicePrincipal - The id of the service that is performing the operation.
userId - The id of the user.
incomingTicketId - The id of the ticket given with the request.
outgoingTicketId - The id of the potentially returned ticket, may be null.
Returns:
The string to be logged.

getLogger

private org.apache.log4j.Logger getLogger()
Returns the logger, instantiates it if not already done. Private, so that nothing is able to override the formatting that is done by generateLogMessage.

Returns:
The logger instance of this class.


Copyright © 2001-2006 UNINETT FAS. All Rights Reserved.