Line number in android log util

for getting line number `

public static int getLineNumber() {
    return Thread.currentThread().getStackTrace()[2].getLineNumber();
}
or 
Thread.currentThread().getStackTrace()[2].getLineNumber()
 in Log()

` try it will help u....


Better Logging In Android Using Timber with Log Line Number

In /app/build.gradle file

implementation 'com.jakewharton.timber:timber:4.7.1'

In Application class

Timber.plant(new Timber.DebugTree() {
                @Override
                protected @Nullable String createStackElementTag(@NotNull StackTraceElement element) {
                    return super.createStackElementTag(element) + ":"+element.getLineNumber();
                }
            });