Failed to instantiate [ch.qos.logback.classic.LoggerContext]

See original GitHub issue

Hi Tony,

I’ve used logback in the past with great love. 😃 Decided to update to latest versions of SLF4J and logback as I am starting another android project.

  • logback-android-1.1.1-2.jar
  • slf4j-api-1.7.6.jar

Searched for answer in this issues list and internet but not found solution yet. Is there another library required? ~~

logback.xml is a bare bones logcat appender case.

<configuration debug="true" >

    <!-- LogCat Appender -->
    <appender
        name="LOGCAT_OUT"
        class="ch.qos.logback.classic.android.LogcatAppender" >
        <!-- Format the message content -->
        <encoder>
            <!-- Simple output -->
            <pattern>%msg%n</pattern>
        </encoder>
    </appender>

    <root level="INFO" >
        <appender-ref ref="LOGCAT_OUT" />
    </root>

</configuration>

However, running the application gives the following error after parsing the root’s appender-ref.


04-01 18:32:45.971: I/System.out(18058): 18:32:45,986 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@36:42 - no applicable action for [appender-ref], current ElementPath  is [[root][appender-ref]]
04-01 18:32:45.981: W/System.err(18058): **Failed to instantiate** [ch.qos.logback.classic.LoggerContext]
04-01 18:32:45.981: W/System.err(18058): Reported exception:
04-01 18:32:45.981: W/System.err(18058): java.util.EmptyStackException

~~ Any help appreciated - Thanks!

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
DevByStarlightcommented, Apr 2, 2014

Followup note: (possible bug?)

If a config.xml uses ‘includes’ to load settings from another child config then apparently the child cannot have ‘configuration’ tags.

[Note: This seems odd since we could use ‘includes’ to replicate the legacy logback-test.xml versus logback.xml loading approach where, presumably, those xml’s would have ‘configuration’ tagged blocks.]

Example: logback.xml

<configuration>
    <includes>
    <include resource="assets/logback-child.xml" />
    </includes>

    <!-- LogCat Appender -->
    <appender name="logcat_dflt" class="ch.qos.logback.classic.android.LogcatAppender" >
        <encoder>
            <pattern>%msg</pattern>
        </encoder>
    </appender>

    <root level="TRACE" >
        <appender-ref ref="logcat_dflt" />
    </root>

</configuration>

The child [apparently] needs to omit the ‘configuration’ tag else the closing tag in the child xml will also close the parsing in the parent such that anything after the ‘includes’ will fail. If debug=“true” then will see “no applicable action” messages for otherwise valid logcat entries.

assets/logback-child.xml

    <!-- Note missing 'configuration' tag. When I have them the logback parsing fails -->

    <!-- Define an output path -->
    <property name="LOG_DIR" value="/sdcard/com.example.package/logs" />

    <!-- Create an appender for trace messages -->
    <appender
        name="TraceLog"
        class="ch.qos.logback.core.FileAppender" >

        <filter class="ch.qos.logback.classic.filter.LevelFilter" >
            <level>TRACE</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>

        <file>${LOG_DIR}/trace.log</file>

        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>


    <logger name="com.example" level="WARN" />
    <logger name="com.example.pacakge.Some" level="INHERITED" />
    <logger name="com.example.pacakge.Other" level="TRACE" >
        <appender-ref ref="TraceLog" />
    </logger>
    <logger name="com.example.pacakge.Thing" level="INHERITED" />

0reactions
lock[bot]commented, Feb 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Boot/Gradle/Logback: bootRun fails with "Failed to ...
Spring Boot/Gradle/Logback: bootRun fails with "Failed to instantiate [ch.qos.logback.classic.LoggerContext]": java.lang.AbstractMethodError:.
Read more >
How to fix ch.qos.logback.classic. LoggerContext [default]
How to fix ch.qos.logback.classic. LoggerContext [default] – Could NOT find resource [logback-test.xml] Info message? (Java).
Read more >
bootRun fails with "Failed to instantiate [ch.qos.logback.classic ...
Coding example for the question Spring Boot/Gradle/Logback: bootRun fails with "Failed to instantiate [ch.qos.logback.classic.LoggerContext]": java.lang.
Read more >
Failed to instantiate [ch.qos.logback.classic.LoggerContext ...
Failed to instantiate [ch.qos.logback.classic.LoggerContext] Reported exception: java.lang.NullPointerException.
Read more >
412012 – Failed to instantiate [ch.qos.logback.classic ... - Bugs
Using PATH instead. Failed to instantiate [ch.qos.logback.classic.LoggerContext] Reported exception: java.lang.reflect.InvocationTargetException ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found