File tree Expand file tree Collapse file tree 4 files changed +34
-1
lines changed
kotlin/com/github/neboskreb/log4j2/examples/migration Expand file tree Collapse file tree 4 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -47,4 +47,11 @@ android {
4747dependencies {
4848 implementation(project(" :examples:migration-lib" ))
4949 implementation ' androidx.core:core-ktx:1.17.0'
50+
51+ implementation ' io.github.neboskreb:android-log4j2-migration:2.0'
52+ implementation ' io.github.neboskreb:android-log4j2:2.24'
53+ // Though android-log4j2 brings Log4J2 in as a transitive dependency,
54+ // it is always a good idea to pin the exact version:
55+ implementation ' org.apache.logging.log4j:log4j-core:2.24.3'
56+ implementation ' org.apache.logging.log4j:log4j-slf4j2-impl:2.24.3'
5057}
Original file line number Diff line number Diff line change 1+ # Root Logger
2+ rootLogger = WARN, LOGCAT
3+
4+ # Direct log messages to LOGCAT
5+ appender.logcat.type = Logcat
6+ appender.logcat.name = LOGCAT
7+ appender.logcat.layout.type = PatternLayout
8+ appender.logcat.layout.pattern = %m%n
9+ # appender.logcat.stack-trace-rendering = log4j
10+ appender.logcat.stack-trace-rendering = logcat
11+
12+
13+ logger.lib.name = MY_LIBRARY
14+ logger.lib.level = warn
15+
16+ logger.app.name = MAIN_ACTIVITY
17+ logger.app.level = all
Original file line number Diff line number Diff line change 11package com.github.neboskreb.log4j2.examples.migration
22
33import android.app.Application
4+ import com.github.neboskreb.log4j2.migration.Log
5+ import net.loune.log4j2android.AndroidLog4jHelper
46
57class App : Application () {
8+ // NOTE: This is optional.
9+ // Force Log to invoke the Log4j calls directly, bypassing the SLF4J facade.
10+ init {
11+ Log .useLog4j2()
12+ }
613
714 override fun onCreate () {
815 super .onCreate()
16+
17+ AndroidLog4jHelper .initialize(applicationContext)
918 }
1019}
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ package com.github.neboskreb.log4j2.examples.migration
22
33import android.app.Activity
44import android.os.Bundle
5- import android.util .Log
5+ import com.github.neboskreb.log4j2.migration .Log
66
77import com.github.neboskreb.log4j2.examples.migration.lib.MyLibrary
88
You can’t perform that action at this time.
0 commit comments