pjsip日志配置未显示android

时间:2017-09-05 08:04:58

标签: java android

使用pjsip(在android中)我只想让我的控制台记录下这样的东西:

    <--- Received SIP request (541 bytes) from UDP:127.0.0.1:5061 --->
INVITE sip:service@127.0.0.1:5060 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5061;branch=z9hG4bK-27600-1-0
From: breakfast <sip:eggowaffles@127.0.0.1:5061>;tag=27600SIPpTag001
To: sut <sip:service@127.0.0.1>
Call-ID: 1-27600@127.0.0.1
CSeq: 1 INVITE
Contact: sip:eggowaffles@127.0.0.1:5061
Max-Forwards: 70
Content-Type: application/sdp
Content-Length:   163

v=0
o=user1 53655765 2353687637 IN IP4 127.0.0.1
s=-
c=IN IP4 127.0.0.1
t=0 0
m=audio 6000 RTP/AVP 0
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=ptime:20

我已经启用了级别:

epConfig.getLogConfig().setLevel(5);
    epConfig.getLogConfig().setConsoleLevel(5);

如何在我的控制台或其他地方查看这些日志?

1 个答案:

答案 0 :(得分:1)

创建LogWriter的子类:

public class SipLogWriter extends LogWriter {
    @Override
    public void write(LogEntry entry) {
        Log.d(TAG, getClass().getSimpleName() + " " + entry.getMsg());
    }
}

使用以下方法覆盖日志级别设置:

epConfig.getLogConfig().setLevel(4);
epConfig.getLogConfig().setConsoleLevel(4);

&#34; epConfig&#34;是你的终点。然后你想设置日志配置:

SipLogWriter logWriter;
LogConfig log_cfg = epConfig.getLogConfig();
        logWriter = new SipLogWriter();
        log_cfg.setWriter(logWriter);
        log_cfg.setDecor(log_cfg.getDecor() & ~(pj_log_decoration.PJ_LOG_HAS_CR.swigValue() | pj_log_decoration.PJ_LOG_HAS_NEWLINE.swigValue()));

如果您使用Android Studio打开Android Monitor进行调试。使用logcat并跟踪&#34; Debug&#34;。您也可以简单地过滤&#34; sip&#34;在搜索/过滤字段中。