Class PayloadLoggerBase<T extends PayloadLoggingContext>

java.lang.Object
org.openehealth.ipf.commons.ihe.core.payload.PayloadLoggerBase<T>
Direct Known Subclasses:
MllpPayloadLoggerBase, WsPayloadLoggerBase

public abstract class PayloadLoggerBase<T extends PayloadLoggingContext> extends Object
Base class for interceptors which store incoming and outgoing payload into files with user-defined name patterns, or to the regular Java log.

File name patterns can contain absolute and relative paths and must correspond to the SpEL syntax, using square brackets for referencing placeholder parameters. In the base version, the following parameters are supported (this set can be extended in derived classes):

  • sequenceId — internally generated sequential ID as a 12-digit positive long int, zero-padded.
  • processId — process ID consisting from the OS process number and the host name, e.g. "12345-myhostname".
  • date('format_spec') — current date and time, formatted using SimpleDateFormat according to the given specification.
  • interactionId — ID of the interaction where the message participates.

Example of a file name pattern:
C:/IPF-LOGS/[processId]/[date('yyyyMMdd-HH00')]/[sequenceId]-server-output.txt
After a pre-configured count of failed trials to create a file, the logger will be switched off.

As an alternative to SpEL, the user can provide another expression resolver.

Furthermore, the behavior of this class is regulated application-widely by the following Boolean system properties:

  • org.openehealth.ipf.commons.ihe.core.payload.PayloadLoggerBase.CONSOLE — when set to true, then the message payload will be logged using regular Java logging mechanisms (level DEBUG) instead of being written into files whose names are created from the pattern.
  • org.openehealth.ipf.commons.ihe.core.payload.PayloadLoggerBase.DISABLED — when set to true, then no logging will be performed at all.
Author:
Dmytro Rud
  • Field Details

    • SEQUENCE_ID_PROPERTY_NAME

      public static final String SEQUENCE_ID_PROPERTY_NAME
    • PROPERTY_CONSOLE

      public static final String PROPERTY_CONSOLE
    • PROPERTY_DISABLED

      public static final String PROPERTY_DISABLED
  • Constructor Details

    • PayloadLoggerBase

      public PayloadLoggerBase()
  • Method Details

    • getNextSequenceId

      protected static Long getNextSequenceId()
    • doLogPayload

      protected void doLogPayload(T context, String charsetName, String... payloadPieces)
    • canProcess

      public boolean canProcess()
    • resetErrorCount

      public void resetErrorCount()
      Resets count of occurred errors, can be used e.g. via JMX.
    • isEnabled

      public boolean isEnabled()
      Returns:
      true if this logging interceptor instance is enabled.
    • setEnabled

      public void setEnabled(boolean enabled)
      Parameters:
      enabled - true when this logging interceptor instance should be enabled.
    • getErrorCountLimit

      public int getErrorCountLimit()
      Returns:
      maximal allowed count of file creation errors, negative value (the default) means "no limit".
    • setErrorCountLimit

      public void setErrorCountLimit(int errorCountLimit)
      Configures maximal allowed count of file creation errors.
      Parameters:
      errorCountLimit - maximal allowed count of file creation errors, negative value (the default) means "no limit".
    • getExpressionResolver

      public ExpressionResolver getExpressionResolver()
    • setExpressionResolver

      public void setExpressionResolver(ExpressionResolver resolver)