Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Feb 21, 2024

Maintenance ModeYou are viewing Amplify Gen 1 documentation. Amplify Gen 1 has entered maintenance mode and will reach end of life on May 1, 2027. New project should use Amplify Gen 2. For existing Gen 1 projects, a migration guide and tooling are available to help you upgrade. Switch to the latest Gen 2 docs →

Listen to log events

The Amplify Logger sends errors that occur when using it through Amplify Hub. To ensure that errors do not occur when logging, log messages should be validated and follow the best security practices. Additionally, you should ensure that log messages do not exceed the Amazon CloudWatch log event size of 256 KB.

You can get logging error events by listening/subscribing to the logging events from the Amplify Hub.

Amplify.Hub.subscribe(HubChannel.LOGGING,
hubEvent -> {
if (hubEvent.getName().equals(LoggingEventName.WRITE_LOG_FAILURE.toString())) {
Log.i("LOGGING", "Failed to write logs");
} else if (hubEvent.getName().equals(LoggingEventName.FLUSH_LOG_FAILURE.toString())){
Log.i("LOGGING", "Failed to flush logs");
}
}
);
Amplify.Hub.subscribe(
HubChannel.LOGGING
) { hubEvent: HubEvent<*> ->
if (hubEvent.name == LoggingEventName.WRITE_LOG_FAILURE.toString()) {
Log.i("LOGGING", "Failed to write logs")
} else if (hubEvent.name == LoggingEventName.FLUSH_LOG_FAILURE.toString()) {
Log.i("LOGGING", "Failed to flush logs")
}
}
RxAmplify.Hub.on(HubChannel.LOGGING)
.map(HubEvent::getName)
.subscribe(name -> {
if (name.equals(LoggingEventName.WRITE_LOG_FAILURE.toString())) {
Log.i("LOGGING", "Failed to write logs");
return;
} else if (name.equals(LoggingEventName.FLUSH_LOG_FAILURE.toString())) {
Log.i("LOGGING", "Failed to flush logs");
return;
}
});