Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use LayoutWrappingEncoder with LogcatAppender #376

Open
3 tasks done
FelixZY opened this issue Sep 23, 2024 · 0 comments
Open
3 tasks done

Cannot use LayoutWrappingEncoder with LogcatAppender #376

FelixZY opened this issue Sep 23, 2024 · 0 comments
Assignees

Comments

@FelixZY
Copy link

FelixZY commented Sep 23, 2024

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 point

logback-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=([^?&amp;\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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants