简体   繁体   English

如何使用android 6.0.1在2013 nexus 7上添加sockethandler到logcat?

[英]How to add a sockethandler to logcat on a 2013 nexus 7 with android 6.0.1?

doing something naive like: 做一些天真的事情:

SocketHandler socketHandler=new SocketHandler(host,service);
socketHandler.setLevel(Level.ALL);
Logger global=Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
global.addHandler(socketHandler);

does not seems to work. 似乎不起作用。

edit: global.severe("foo") does work. 编辑:global.severe(“foo”)确实有效。 but the rest of the logcat messages do not appear. 但其余的logcat消息不会出现。

i would like all (or most) of the logcat messages to go to the log server. 我希望所有(或大多数)logcat消息都转到日志服务器。

I think you also need LogRecord , see example below: 我想你也需要LogRecord ,见下面的例子:

    Logger logger = Logger.getLogger("concrete.log");

    Handler handle = new SocketHandler("localhost", 8080);

    LogRecord logRec = new LogRecord(Level.INFO, "Log will be recorded");

    handle.publish(logRec);

    handle.setFormatter(new XMLFormatter());

    logger.addHandler(handle);

    logger.info("socket handler info message");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM