C# V4 SDK Troubleshooting Guide
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. Not setting the UUID
can significantly impact your billing if your account uses the Monthly Active Users (MAUs) based pricing model, and can also lead to unexpected behavior if you have Presence enabled.
PNConfiguration config = new PNConfiguration();
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));
}
public void WriteToLog(string log) {
//Save to text file or DB or any storage
Trace.WriteLine(log);
Trace.Flush();
}
}