Package org.pipservices3.components.log
Class CompositeLogger
java.lang.Object
org.pipservices3.components.log.Logger
org.pipservices3.components.log.CompositeLogger
- All Implemented Interfaces:
org.pipservices3.commons.config.IConfigurable
,org.pipservices3.commons.config.IReconfigurable
,org.pipservices3.commons.refer.IReferenceable
,ILogger
public class CompositeLogger extends Logger
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)
ILogger
components to pass log messages
### Example ###
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 Also:
ILogger
-
Field Summary
-
Constructor Summary
Constructors Constructor Description CompositeLogger()
Creates a new instance of the logger.CompositeLogger(org.pipservices3.commons.refer.IReferences references)
Creates a new instance of the logger. -
Method Summary
-
Constructor Details
-
CompositeLogger
public CompositeLogger()Creates a new instance of the logger. -
CompositeLogger
public CompositeLogger(org.pipservices3.commons.refer.IReferences references) throws org.pipservices3.commons.refer.ReferenceExceptionCreates a new instance of the logger.- Parameters:
references
- references to locate the component dependencies.- Throws:
org.pipservices3.commons.refer.ReferenceException
- when no references found
-
-
Method Details
-
setReferences
public void setReferences(org.pipservices3.commons.refer.IReferences references)Sets references to dependent components.- Specified by:
setReferences
in interfaceorg.pipservices3.commons.refer.IReferenceable
- Overrides:
setReferences
in classLogger
- Parameters:
references
- references to locate the component dependencies.
-
write
Writes a log message to the logger destination(s).
-