我正在 iOS 中使用 xmppframework 开发聊天应用程序。该框架包含打印 xml 发送和接收日志的示例演示。现在我在我的应用程序中实现了相同的功能,但没有显示任何日志。
示例应用程序的日志示例
2014-05-08 16:34:15:993 iPhoneXMPP[4839:1403] SEND: <?xml version='1.0'?>
2014-05-08 16:34:15:994 iPhoneXMPP[4839:1403] SEND: <stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='meinantrieb.net'>
2014-05-08 16:34:16:384 iPhoneXMPP[4839:3503] RECV: <stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" id="1364620848" from="meinantrieb.net" version="1.0" stream1:lang="en"/>
2014-05-08 16:34:16:384 iPhoneXMPP[4839:3503] RECV: <stream:features xmlns:stream="http://etherx.jabber.org/streams"><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>SCRAM-SHA-1</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.process-one.net/en/ejabberd/" ver="GgBjinftMQ4H81m+4jSVXMg/dVU="/><register xmlns="http://jabber.org/features/iq-register"/></stream:features>
AppDelegate.m中添加日志的代码
#import "DDLog.h" #import "DDTTYLogger.h" // Log levels: off, error, warn, info, verbose #if DEBUG static const int ddLogLevel = LOG_LEVEL_VERBOSE; #else static const int ddLogLevel = LOG_LEVEL_INFO; #endif
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Configure logging framework
[DDLog addLogger:[DDTTYLogger sharedInstance]];
}
我们将不胜感激任何帮助或建议。
最佳答案
用这一行替换配置日志框架的代码
[DDLog addLogger:[DDTTYLogger sharedInstance] withLogLevel:XMPP_LOG_FLAG_SEND_RECV]
复制自XMPPFramework的demo代码
关于ios - xmppframework - 为发送/接收启用日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23540079/