C#C# V4 SDK Troubleshooting Guide

 

These docs are for PubNub 4.0 for C# which is our latest and greatest! For the docs of the 3.x versions of the SDK, please check the links: C#, Windows 8, Windows 8.1, ASP.Net, Windows Phone 8, Windows Phone 8.1, Xamarin.iOS, Xamarin.Android, Xamarin.Mac and C# PCL.

If you have questions about the PubNub for C# SDK, please contact us at support@pubnub.com.

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();
    }
}