-
-
Notifications
You must be signed in to change notification settings - Fork 176
Open
Labels
Description
Describe the bug
I'm trying to follow this guide to mask certain patterns before they show up in logs. However, it seems LogcatAppender does not support changing the <encoder> to LayoutWrappingEncoder.
Reproduction
https://www.baeldung.com/logback-mask-sensitive-data
Logs
Click to expand!
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,909 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [assets/logback.xml] at [assets/logback.xml]
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,909 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@3893637 - URL [jar:file:/data/app/com.example.myapp-nj2LI1lYKwhTc2KSqGp_1g==/base.apk!/assets/logback.xml] is not of type file
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,917 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,917 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.android.LogcatAppender]
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,920 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [logcat]
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,922 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [tagEncoder] property
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,935 |-ERROR in ch.qos.logback.core.joran.util.PropertySetter@57b07a4 - A "ch.qos.logback.core.encoder.LayoutWrappingEncoder" object is not assignable to a "ch.qos.logback.classic.encoder.PatternLayoutEncoder" variable.
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,935 |-ERROR in ch.qos.logback.core.joran.util.PropertySetter@57b07a4 - The class "ch.qos.logback.classic.encoder.PatternLayoutEncoder" was loaded by
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,935 |-ERROR in ch.qos.logback.core.joran.util.PropertySetter@57b07a4 - [dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.myapp-nj2LI1lYKwhTc2KSqGp_1g==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.myapp-nj2LI1lYKwhTc2KSqGp_1g==/lib/x86, /system/lib, /system/product/lib]]]] whereas object of type
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,935 |-ERROR in ch.qos.logback.core.joran.util.PropertySetter@57b07a4 - "ch.qos.logback.core.encoder.LayoutWrappingEncoder" was loaded by [dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.myapp-nj2LI1lYKwhTc2KSqGp_1g==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.myapp-nj2LI1lYKwhTc2KSqGp_1g==/lib/x86, /system/lib, /system/product/lib]]]].
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,935 |-ERROR in ch.qos.logback.classic.android.LogcatAppender[logcat] - No layout set for the appender named [logcat].
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,935 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,935 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [logcat] to Logger[ROOT]
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,935 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
2024-09-23 14:53:03.937 18764-18764 System.out com.example.myapp I 14:53:03,935 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@e8e690d - Registering current configuration as safe fallback pointlogback-android version
3.0.0
OS Version
14
What logback configuration are you using? (logback.xml or Java/Kotlin code)
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://tony19.github.io/logback-android/xml"
xsi:schemaLocation="https://tony19.github.io/logback-android/xml https://cdn.jsdelivr.net/gh/tony19/logback-android/logback.xsd">
<appender name="logcat" class="ch.qos.logback.classic.android.LogcatAppender">
<tagEncoder>
<pattern>%logger{12}</pattern>
</tagEncoder>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="com.example.myapp.MaskingPatternLayout">
<maskPattern>masked=([^?&\s]+)</maskPattern>
<pattern>%msg</pattern>
</layout>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="logcat" />
</root>
</configuration>Validations
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- The provided reproduction is a minimal reproducible of the bug.