PubNub LogoDocs
SupportContact SalesLoginTry Our APIs

›pHP

pHP

  • Getting Started
  • API Reference

    • Configuration
    • Publish & Subscribe
    • Presence
    • Access Manager
    • Channel Groups
    • Message Persistence
    • Mobile Push
    • Objects
    • Miscellaneous
  • Status Events
  • Troubleshooting
  • Change Log
  • Feature Support
  • Platform Support

Troubleshooting PubNub Php SDK

How to enable logging

Note

Always set the UUID to uniquely identify the user or device that connects to PubNub. This UUID should be persisted, and should remain unchanged for the lifetime of the user or the device. If you don't set the UUID, you won't be able to connect to PubNub.

use Monolog\Handler\ErrorLogHandler;
use PubNub\PNConfiguration;
use PubNub\PubNub;

$pnconf = new PNConfiguration();

$pnconf->setPublishKey("pub_key");
$pnconf->setSubscribeKey("sub_key");

$pubnub = new PubNub($pnconf);

$pubnub->getLogger()->pushHandler(new ErrorLogHandler());

How to disable logging

You can disable the STDOUT print statements by configuring Monolog to use a different handler. Using Monolog\Handler\NullHandler instead of Monolog\Handler\ErrorLogHandler is the best option.

Using this code sample you can discard all log message output:

use Monolog\Handler\NullHandler;
use PubNub\PNConfiguration;
use PubNub\PubNub;

$pnconf = new PNConfiguration();

$pnconf->setPublishKey("pub_key");
$pnconf->setSubscribeKey("sub_key");

$pubnub = new PubNub($pnconf);

$pubnub->getLogger()->pushHandler(new Nullhandler());
← Status EventsChange Log →
  • How to enable logging
  • How to disable logging
© PubNub Inc. - Privacy Policy