Skip to content

Commit 6ebc426

Browse files
committed
Improve Android example
1 parent 3088609 commit 6ebc426

File tree

9 files changed

+202
-148
lines changed

9 files changed

+202
-148
lines changed

log4j-samples-android/app/build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ plugins {
2020

2121
android {
2222
compileSdk 34
23+
namespace "org.apache.logging.log4j.samples.android"
2324

2425
defaultConfig {
2526
applicationId "org.apache.logging.log4j.samples.android"
@@ -50,15 +51,16 @@ android {
5051

5152
dependencies {
5253

53-
implementation 'androidx.appcompat:appcompat:1.6.1'
54-
implementation 'com.google.android.material:material:1.11.0'
54+
implementation 'androidx.appcompat:appcompat:1.7.0'
55+
implementation 'com.google.android.material:material:1.12.0'
5556
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
5657

5758
testImplementation 'junit:junit:4.13.2'
5859
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
5960
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
6061

61-
//Log4j
62+
// Log4j
6263
implementation 'org.apache.logging.log4j:log4j-api:2.25.0-SNAPSHOT'
6364
implementation 'org.apache.logging.log4j:log4j-core:2.25.0-SNAPSHOT'
64-
}
65+
66+
}

log4j-samples-android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
~ limitations under the License.
1717
-->
1818
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
19-
xmlns:tools="http://schemas.android.com/tools"
20-
package="org.apache.logging.log4j.samples.android">
19+
xmlns:tools="http://schemas.android.com/tools">
2120

2221
<application
2322
android:allowBackup="true"

log4j-samples-android/app/src/main/resources/log4j2.properties renamed to log4j-samples-android/app/src/main/resources/log4j2.StatusLogger.properties

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,5 @@
1515
# limitations under the License.
1616
#
1717
##
18-
# Appenders
19-
appender.console.type = Console
20-
appender.console.name = CONSOLE
21-
appender.console.layout.type = PatternLayout
22-
appender.console.layout.pattern = [%d{yyyy-MM-dd HH:mm:ss.SSS}] %-5p- %m%n
23-
24-
# Loggers
25-
rootLogger.level = INFO
26-
rootLogger.appenderRef.stdout.ref = CONSOLE
27-
28-
logger.0.name = org.apache.logging.log4j.samples.android.MainActivity
29-
logger.0.level = DEBUG
18+
# Set the level to `WARN`
19+
log4j2.statusLoggerLevel = WARN

log4j-samples-android/app/src/main/resources/log4j2.component.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
#
1717
##
1818
log4j2.debug = true
19-
log4j2.contextSelector = org.apache.logging.log4j.core.selector.BasicContextSelector
19+
log4j2.contextSelector = org.apache.logging.log4j.core.selector.ClassLoaderContextSelector
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to you under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
<Configuration xmlns="https://logging.apache.org/xml/ns"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="
21+
https://logging.apache.org/xml/ns
22+
https://logging.apache.org/xml/ns/log4j-config-2.xsd">
23+
<Appenders>
24+
<Console name="CONSOLE">
25+
<PatternLayout pattern="%d %-5p [%t] %C:%M - %m%n"/>
26+
</Console>
27+
</Appenders>
28+
<Loggers>
29+
<Root level="INFO">
30+
<AppenderRef ref="CONSOLE"/>
31+
</Root>
32+
<Logger name="org.apache.logging.log4j.samples.android.MainActivity"
33+
level="DEBUG"/>
34+
</Loggers>
35+
</Configuration>

log4j-samples-android/build.gradle

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
* limitations under the License.
1616
*/
1717
plugins {
18-
id 'com.android.application' version '7.2.1' apply false
19-
id 'com.android.library' version '7.2.1' apply false
18+
id 'com.android.application' version '8.2.0' apply false
19+
id 'com.android.library' version '8.2.0' apply false
2020
}
21-
22-
tasks.register('clean', Delete) {
23-
delete rootProject.buildDir
24-
}
333 Bytes
Binary file not shown.
Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
1-
#
2-
# Licensed to the Apache Software Foundation (ASF) under one or more
3-
# contributor license agreements. See the NOTICE file distributed with
4-
# this work for additional information regarding copyright ownership.
5-
# The ASF licenses this file to you under the Apache License, Version 2.0
6-
# (the "License"); you may not use this file except in compliance with
7-
# the License. You may obtain a copy of the License at
8-
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,
13-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
# See the License for the specific language governing permissions and
15-
# limitations under the License.
16-
#
17-
##
181
distributionBase=GRADLE_USER_HOME
19-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
202
distributionPath=wrapper/dists
21-
zipStorePath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
224
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)