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

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;
}
});