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 SocketAppender host is a domain name #90

Closed
tjanson opened this issue Mar 14, 2015 · 6 comments
Closed

Comments

@tjanson
Copy link

tjanson commented Mar 14, 2015

I’m successfully using a SocketAppender to log to a remote server when the host is set as an IP address. However, when specifying a domain name as host (otherwise identical configuration), I get a NetworkOnMainThreadExcept during startup. Possible problem: The “Lazy” setting does not seem to work.

The configuration file (and in fact the entire project) is here on Github; Log showing the exception, excerpt:

03-14 23:21:13.927 32036-32036/com.tomjanson.wifilocationlogger I/System.out﹕ 23:21:13,927 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.net.SocketAppender]
03-14 23:21:13.930 32036-32036/com.tomjanson.wifilocationlogger I/System.out﹕ 23:21:13,930 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [SOCKET]
03-14 23:21:13.938 32036-32036/com.tomjanson.wifilocationlogger I/System.out﹕ 23:21:13,938 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@57:15 - no applicable action for [lazy], current ElementPath is [[configuration][appender][lazy]]
03-14 23:21:13.967 32036-32036/com.tomjanson.wifilocationlogger I/System.out﹕ 23:21:13,965 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@63:16 - RuntimeException in Action for tag [appender] android.os.NetworkOnMainThreadException
@gauravdott
Copy link

Same problem. Did you figure out the solution?

@tjanson
Copy link
Author

tjanson commented Mar 26, 2015

I worked around it by simply entering my server’s (thankfully static) IP address.

@gauravdott
Copy link

ok, that's not an option for me. Thanks for reply anyway

@tony19
Copy link
Owner

tony19 commented Dec 11, 2015

@gauravdott, Indeed, the lazy flag was unintentionally removed during a merge from the main logback project that completely rewrote the SocketAppender. I started to restore that feature in a branch.

I think this issue is actually a duplicate of #65.

@tony19 tony19 added the bug label Dec 11, 2015
@tony19
Copy link
Owner

tony19 commented Dec 11, 2015

A possible workaround is to use AsyncAppender as seen with this SocketAppender example. Let me know if that helps.

@stale stale bot added the wontfix label Mar 27, 2018
@tony19 tony19 added pinned and removed wontfix labels Mar 27, 2018
Repository owner deleted a comment from stale bot Mar 27, 2018
@tony19
Copy link
Owner

tony19 commented Nov 6, 2022

Closing this stale issue, as there's workaround in place (see previous comment). Please create a new issue if the issue resurfaces.

@tony19 tony19 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants