CloudWatchLogger

Logger that writes log messages to AWS CloudWatch Log.

Implements: IConfigurable, IReferenceable

Extends: CachedLogger

Description

The CloudWatchLogger class allows you to create loggers that write log messages to AWS CloudWatch Log.

Configuration parameters

  • stream: (optional) CloudWatch Log stream (default: context name)
  • group: (optional) CloudWatch Log group (default: context instance ID or hostname)
  • connections:
    • discovery_key: (optional) key to retrieve the connection from IDiscovery
    • region: (optional) AWS region
  • credentials:
    • store_key: (optional) key to retrieve the credentials from ICredentialStore
    • access_id: AWS access/client id
    • access_key: AWS access/client key
  • options:
    • interval: interval in milliseconds to save current counters measurements (default: 5 mins)
    • reset_timeout: timeout in milliseconds to reset the counters. 0 disables the reset (default: 0)

References

  • *:context-info:*:*:1.0 - (optional) ContextInfo to detect the context id and specify the counters' source
  • *:discovery:*:*:1.0 - (optional) IDiscovery services to resolve connections
  • *:credential-store:*:*:1.0 - (optional) credential stores used to resolve credentials requests

Constructors

Creates a new instance of this logger.

public constructor()

Instance methods

close

Closes a component and frees used resources.

public void close(IContext context) throws InvocationException

  • context: IContext - (optional) a context to trace execution through a call chain.

configure

Configures a component by passing configuration parameters.

public void configure(ConfigParams config)

  • config: ConfigParams - configuration parameters to be set.

isOpen

Checks if the component is open.

public boolean isOpen()

  • returns: boolean - true if the component is open and false otherwise.

open

Opens the component.

public void open(IContext context) throws ApplicationException

  • context: IContext - (optional) a context to trace execution through a call chain.

save

Saves the current counters' measurements.

protected void save(List<LogMessage[]> messages) throws InvocationException

  • messages: LogMessage[] - current counters' measurements to be saved.

setReferences

Sets references to dependent components.

public void setReferences(IReferences references)

  • references: IReferences - references to locate the component’s dependencies.

write

Writes a log message to the logger destination.

protected void write(LogLevel level, IContext context, Exception ex, String message)

  • level: LogLevel - log level.
  • context: IContext - (optional) a context to trace execution through a call chain.
  • ex: Error - error object associated with this message.
  • message: string - human-readable message to log.

Examples

See also