# Jealous of Timber logging for a plain Java app

**URL:** <https://discuss.kotlinlang.org/t/jealous-of-timber-logging-for-a-plain-java-app/9638>\
**Category:** Libraries\
**Created:** [October 1, 2018, 2:57am UTC](https://discuss.kotlinlang.org/t/jealous-of-timber-logging-for-a-plain-java-app/9638 "2018-10-01T02:57:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjaminhill](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/32.png) [@benjaminhill](https://discuss.kotlinlang.org/u/benjaminhill)\
**Post date:** [October 1, 2018, 2:57am UTC](https://discuss.kotlinlang.org/t/jealous-of-timber-logging-for-a-plain-java-app/9638/1 "2018-10-01T02:57:02Z")

</div>

I started using timber with timberkt in Android, and it was `i { "Very cool." }`  
It was everything I wanted for prototyping:

- no worrying about logger instantiation
- lazy eval of the logging string or lambda
- very short and clear code.

I’m writing a Kotlin app that runs in plain old JVM (no Android) and I miss Timber. Is there anything that hits those three (tree?) points and would let me `d { "easily log stuff?" }`

---

<div class="post-metadata">

**Author:** ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Post date:** [October 1, 2018, 5:14am UTC](https://discuss.kotlinlang.org/t/jealous-of-timber-logging-for-a-plain-java-app/9638/2 "2018-10-01T05:14:40Z")

</div>

You can always write simple aliases for standard loggers like

```kotlin
fun i(message: String, vararg parameters: Any){
  LoggerFactory.getLogger(javaClass).info(message,*parameters)
}

```

for slf4j.

You do not have to bother with instantiation. Arguments evaluated lazily by default and it does not make sense to evaluate simple string constant in lambda, it just creates unnecessary overhead. The name is one-letter, though I do not recommend it. Call it at least `logInfo`. Readability is much more important. At the end, you can’t protect forests by writing less letters in the code.

---

<div class="post-metadata">

**Author:** ![benjaminhill](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/32.png) [@benjaminhill](https://discuss.kotlinlang.org/u/benjaminhill)\
**Post date:** [October 1, 2018, 5:52am UTC](https://discuss.kotlinlang.org/t/jealous-of-timber-logging-for-a-plain-java-app/9638/3 "2018-10-01T05:52:35Z")

</div>

Sure, the “i” vs “logInfo” - either works!

But I did like the idea of an import, then being able to drop `logInfo { "some lazy thing" }` anywhere and get all the niceness of Timber.

But if there is some simple way to do logging that doesn’t take much 'learnin on my part and lets me not care about the details (calling from main, a class, or inside a companion, because I’m just prototyping) - even better.

---

<div class="post-metadata">

**Author:** ![oshai](https://avatars.discourse-cdn.com/v4/letter/o/85e7bf/32.png) [@oshai](https://discuss.kotlinlang.org/u/oshai)\
**Post date:** [October 1, 2018, 6:30pm UTC](https://discuss.kotlinlang.org/t/jealous-of-timber-logging-for-a-plain-java-app/9638/4 "2018-10-01T18:30:41Z")

</div>

you can try to take a look at [kotlin-logging](https://github.com/MicroUtils/kotlin-logging), it is not that simple but gives pretty idiomatic logging in kotlin. There is also this question in SO with other possibilities: [Idiomatic way of logging in Kotlin - Stack Overflow](https://stackoverflow.com/questions/34416869/idiomatic-way-of-logging-in-kotlin)

---

<div class="post-metadata">

**Author:** ![benjaminhill](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/32.png) [@benjaminhill](https://discuss.kotlinlang.org/u/benjaminhill)\
**Post date:** [March 11, 2019, 10:23pm UTC](https://discuss.kotlinlang.org/t/jealous-of-timber-logging-for-a-plain-java-app/9638/5 "2019-03-11T22:23:54Z")

</div>

> [@oshai](#):
>
> you can try to take a look at [kotlin-logging](https://github.com/MicroUtils/kotlin-logging)

That worked great for me, thank you!
