Troubleshooting PubNub C# SDK
How to enable logging
Required UserId
Always set the UserId
to uniquely identify the user or device that connects to PubNub. This UserId
should be persisted, and should remain unchanged for the lifetime of the user or the device. If you don't set the UserId
, you won't be able to connect to PubNub.
PNConfiguration config = new PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"));
config.LogVerbosity = PNLogVerbosity.BODY;
config.PubnubLog = new PlatformPubnubLog(); //Capture the log information
public class PlatformPubnubLog : IPubnubLog {
private string logFilePath = "";
public PlatformPubnubLog() {
// Get folder path may vary based on environment
string folder = System.IO.Directory.GetCurrentDirectory(); //For console
//string folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); // For iOS
System.Diagnostics.Debug.WriteLine(folder);
logFilePath = System.IO.Path.Combine(folder, "pubnubmessaging.log");
Trace.Listeners.Add(new TextWriterTraceListener(logFilePath));
}
show all 21 lines