Replies: 1 comment
-
Did you try something like this? class CrashlyticsAppender(
private val encoder: PatternLayoutEncoder
) : AppenderBase<ILoggingEvent>() {
override fun append(eventObject: ILoggingEvent) {
try {
FirebaseCrashlytics.getInstance().log(encoder.layout.doLayout(eventObject))
} catch (e: Exception) {
addError("Failed to log to Crashlytics", e)
}
}
} It may require some adjustments, e.g. enabling/disabling Crashlytics in runtime based on user's choice or making sure that And then you must add the appender. I haven't used the XML configs so I can only explain how it can be done programmatically instead: val lc = LoggerFactory.getILoggerFactory() as ch.qos.logback.classic.LoggerContext
val crashlyticsEncoder = PatternLayoutEncoder()
crashlyticsEncoder.context = lc
crashlyticsEncoder.pattern = "[%thread] %msg%n" // modify this as you wish
crashlyticsEncoder.start()
val crashlyticsAppender = CrashlyticsAppender(crashlyticsEncoder)
crashlyticsAppender.context = lc
crashlyticsAppender.start()
val root = LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME) as ch.qos.logback.classic.Logger
root.addAppender(crashlyticsAppender) Note it's only a snippet and not a full configuration. Please follow some examples that you can easily find elsewhere e.g. https://stackoverflow.com/questions/16910955/programmatically-configure-logback-appender |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to add Crashlytics Logger as an appender. So that when there is a crash on Crashlytics we have the latest logs which were logged using the logback.
Beta Was this translation helpful? Give feedback.
All reactions