org.pipservices3.components.log.CompositeLogger Maven / Gradle / Ivy
package org.pipservices3.components.log;
import java.util.*;
import org.pipservices3.commons.refer.*;
/**
* Aggregates all loggers from component references under a single component.
*
* It allows to log messages and conveniently send them to multiple destinations.
*
* ### References ###
*
* - *:logger:*:*:1.0 (optional) {@link ILogger} components to pass log messages
*
*
* ### Example ###
*
* {@code
* class MyComponent implements IConfigurable, IReferenceable {
* CompositeLogger _logger = new CompositeLogger();
*
* public void configure(ConfigParams config) {
* this._logger.configure(config);
* ...
* }
*
* public void setReferences(IReferences references) {
* this._logger.setReferences(references);
* ...
* }
*
* public void myMethod(String correlationId) {
* this._logger.debug(correlationId, "Called method mycomponent.mymethod");
* ...
* }
* }
* }
*
* @see ILogger
*/
public class CompositeLogger extends Logger {
private List _loggers = new ArrayList();
/**
* Creates a new instance of the logger.
*/
public CompositeLogger() {
}
/**
* Creates a new instance of the logger.
*
* @param references references to locate the component dependencies.
* @throws ReferenceException when no references found
*/
public CompositeLogger(IReferences references) throws ReferenceException {
setReferences(references);
}
/**
* Sets references to dependent components.
*
* @param references references to locate the component dependencies.
*/
@Override
public void setReferences(IReferences references) {
List