Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log.e with Kotlin

Tags:

android

kotlin

As we have used Log.e() for logging error with java code. I was looking for same functionality with Kotlin. Though i have found Logger class

val Log = Logger.getLogger(MainActivity::class.java.name)
Log.warning("Hello World")

It is showing log in android studio logcat.

But does there any way to print log in red color the same way Log.e() does?

like image 348
Ravi Avatar asked May 24 '17 12:05

Ravi


Video Answer


2 Answers

You can use log like this Log.d(TAG, "my Message") in KOTLIN

like image 99
yatin deokar Avatar answered Sep 24 '22 02:09

yatin deokar


Log.e() will work perfectly in Kotlin.

In Kotlin, we also have a Logger class to log something.

Logger.getLogger(Test::class.java.name).warning("Hello..")

Otherwise, you have to use some other library like: kotlin-logging, anko logging etc.

like image 45
Avijit Karmakar Avatar answered Sep 24 '22 02:09

Avijit Karmakar