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

NetworkOnMainThreadException when using socket appender with async appender #91

Closed
gauravdott opened this issue Mar 26, 2015 · 2 comments
Labels

Comments

@gauravdott
Copy link

Here is configuration in assets/logback.xml

<?xml version="1.0" encoding="utf-8"?>
<configuration debug="true">

    <appender name="SOCKET" class="ch.qos.logback.classic.net.SocketAppender">
        <!-- lazy initialization: don't open socket until 1st write -->
        <lazy>true</lazy>

        <remoteHost>###My host name here</remoteHost>
        <port>80</port>
        <reconnectionDelay>10000</reconnectionDelay>
        <includeCallerData>true</includeCallerData>

        <encoder>
            <pattern>%d{ISO8601} %p %t %c{0}.%M - %m%</pattern>
        </encoder>

    </appender>

    <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
        <appender-ref ref="SOCKET" />
    </appender>

    <root level="info">
        <appender-ref ref="ASYNC" />
    </root>
    <root level="debug">
        <appender-ref ref="ASYNC" />
    </root>
    <root level="error">
        <appender-ref ref="ASYNC" />
    </root>
    <root level="warn">
        <appender-ref ref="ASYNC" />
    </root>
</configuration>

Also I am closing the logger context in onDestroy

@Override
    protected void onDestroy() {
        super.onDestroy();
        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
        loggerContext.stop();
    }

Can anybody suggest a solution?

@tony19
Copy link
Owner

tony19 commented Mar 27, 2015

This is a duplicate of #90.

Unrelated problem: your configuration contains too many <root> entries. You only need one. If you want your root logger to capture all logs, simply set the level to debug, which would include all log levels.

@tony19 tony19 closed this as completed Mar 27, 2015
@lock
Copy link

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.

@lock lock bot added the archived label Feb 27, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants