Logging not appearing in LogCat KMM Compose
Hello I integrated kotlin-logging into my project but when I use the logger in my classes nothing appear in LogCat.
Code in common:
val logger = KotlinLogging.logger {}
@Composable
@Preview
fun App(
onSplashFinished: () -> Unit = {}
) {
logger.debug { "Testing!" }
AppTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = Color.Transparent
) {
val navController = rememberNavController()
// val screen by splashViewModel.state
MainGraph(
navController = navController,
onDataLoaded = onSplashFinished
)
}
}
}
Nothing appears in LogCat. I added this to common dependencies in my KMM Compose project:
kotlinLogging = "7.0.3"
kotlin-logging = { module = "io.github.oshai:kotlin-logging", version.ref = "kotlinLogging" }
Thank you for reporting an issue. See the wiki for documentation and slack for questions.
Maybe you need to place a simplelogger.properties in your resources directory if you are using org.slf4j:slf4j-simple. See here: How to configure slf4j-simple
Would this be in Shared Resource or Android Resource?
Any update on the issue?
I have the same problem
Did you try logging other levels like error?
Have you tried following https://github.com/oshai/kotlin-logging/wiki/Multiplatform-support#android-usage ?
Similar problem here :
I work on a library for android with "com.android.kotlin.multiplatform.library" plugin. I managed to run deviceTests with
withDeviceTestBuilder { }.configure {
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
packaging {
resources.excludes.add("META-INF/*")
}
}
however i don't get any debug logs.
@Test
fun testLogging(){
logger.debug { "kt debug" }
logger.error { "kt error" }
Log.d("android", "DEBUG")
}
for example gives: 08-25 15:40:52.802 18717 18734 E CENSORED: kt error 08-25 15:40:52.802 18717 18734 D android : DEBUG
so kotlin logging works but debug level is filtered.
tried
object Static {
init {
System.setProperty("kotlin-logging-to-android-native", "true")
}
}
private val static = Static
in @BeforeTest and in my classes, with no luck
never mind - just had to find the right place for config.properties of https://github.com/nomis/slf4j-android
which is
src/androidDeviceTest/resources/uk/uuid/slf4j/android/config.properties
entry there is: level=DEBUG
now i got my logs
--