Output to the log

1 Answer 1717 Views
Fiddler Classic
Aleksander
Top achievements
Rank 1
Aleksander asked on 20 Aug 2021, 12:12 PM

I'm trying to output information to the log, I do " Console.Write("22s");" . After looking at the Log, I do not find this text there. How to correctly output it to Log?

 

     if (oSession.url.Contains("google.com")) {
            Console.Out.Write("22s");
        }

1 Answer, 1 is accepted

Sort by
1
Nick Iliev
Telerik team
answered on 20 Aug 2021, 02:29 PM | edited on 24 Aug 2023, 12:46 PM

Hello Alexander,

Fiddler 2.2.8 introduced a lightweight Logging mechanism.

From FiddlerScript, you can do this:
FiddlerObject.log("Your message here");
From a Fiddler extension, do this:
FiddlerApplication.Log.LogString("Your message here");
If you want to get copies of log messages, write the following code in your extension:
FiddlerApplication.Log.OnLogString += new EventHandler<LogEventArgs>(YourEventHandler);
  
and implement an event handler to capture log events. Because logging may occur from background threads, you should use Invoke or BeginInvoke to marshal any UI updates to the UI thread:
public delegate void LogAString(string Str);
 
void YourEventHandler(object sender, LogEventArgs e)
{
    FiddlerApplication.UI.BeginInvoke(new LogAString(LogOnMainThread), new object[] { e.LogString });
}
 
void LogOnMainThread(string sMsg]
{
    oLogUI.txtLog.AppendText(String.Format("{0} {1} \r\n", DateTime.Now.ToString("HH:mm:ss:ffff"), sMsg));
}


Regards,
Nick Iliev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Aleksander
Top achievements
Rank 1
commented on 20 Aug 2021, 03:12 PM

Thanks! That's great! I also found a way for myself to MessageBox.Show("Hello");
Tags
Fiddler Classic
Asked by
Aleksander
Top achievements
Rank 1
Answers by
Nick Iliev
Telerik team
Share this question
or