Welcome Guest Search | Active Topics | Sign In | Register

Recommended logging required by EO support to troubleshoot Options
Phil
Posted: Monday, June 19, 2023 6:37:08 AM
Rank: Advanced Member
Groups: Member

Joined: 11/8/2017
Posts: 64
Hello, we are using EO-PDF v23.1.77 (we are currently testing to v23.2.34 to check its stability) from a web application using Angular 14 hosted on AppServices. Can we have a definitive/recommended means to get sufficient logs so we can handover to yourselves when a failure occurs. Currently our process looks like the following

Code: C#
HtmlToPdfResult htmlToPdfResult = null;
using (var debugConsoleLog = new StringWriter())
{
    HtmlToPdf.DebugConsole = debugConsoleLog;
    using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
    {
        try
        {
            htmlToPdfResult = HtmlToPdf.ConvertHtml(inputHtml, stream);
        }
        catch (Exception outerEx)
        {
            try
            {
                string log = EO.Base.Runtime.GetLogs();
                System.IO.File.WriteAllText(FULL_LOG_PATH_AND_FILENAME, log);
            }
            catch (Exception getLogsEx)
            {
                //Generate PDF error-GetLogs failed - write getLogsEx to application log file
                throw;
            }
            try
            {
                EO.Base.DiagnosticTools.CaptureDump(CAPTURE_LOG_FILENAME);
            }
            catch (Exception captureDumpEx)
            {
                //Generate PDF error-CaptureDump failed - write captureDumpEx to application log file
                throw;
            }
            //Generate PDF error-throw - write outerEx to application log file
            throw;
        }
        bytes = stream.ToArray();
    }
    debugConsoleLog.Flush();
    //write debugConsoleLog.ToString() to application log file
}


A couple of questions on the above
- what exactly is expected to be passed to EO.Base.DiagnosticTools.CaptureDump(filename) - https://www.essentialobjects.com/doc/eo.base.diagnostictools.capturedump.html - in the past I have passed it a filename (no path) as I wasn't sure what was required and a file was written to the root folder of the website, however now I am getting
System.Exception: Can not capture some debug information due to insuficient permission.
at EO.Base.DiagnosticTools.CaptureDump(String fileName)
- although the call to EO.Base.Runtime.GetLogs() runs, there seems to be a delay when the output file is written - it's unclear what the delay is - is it when the AppService slot/service is restarted
eo_support
Posted: Monday, June 19, 2023 11:16:12 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi,

Generally you should only use:

Code: C#
EO.Base.Runtime.GetLogs();


If this step fails for whatever reason, then it is unlikely the app will be "healthy" enough to collect more detailed debug information with CaptureDump. We do recommend you to also write outerEx.ToString() to your log file because that would include the call stack that caused ConvertHtml to fail and most of the time that's very helpful.

CaptureDump is a much more "invasive" methods as it tries to start a mini debugger and then put the application under debug mode. This requires elevated permissions as debugging an application can have security implications, thus it often requires you to run your application as Administrator. As a result, this method is only recommended for testing/troubleshooting purpose. It is not recommended to be used in production.

Both GetLogs and CaptureDump will have a delay, but CaptureDump's delay is signficaintly greater due to the fact it needs to put the application under debug mode. GetLogs delay should not exceed a few seconds though, particularly it should not delay until your AppService restarts.

Hope this answers your question. Please feel free to let us know if you have any more questions.

Thanks!
Phil
Posted: Monday, June 19, 2023 5:42:50 PM
Rank: Advanced Member
Groups: Member

Joined: 11/8/2017
Posts: 64
Many thanks for the reply

Is the recommended approach to collect either/both GetLogs and/or CaptureDump from within the Exception event ( https://www.essentialobjects.com/doc/EO.Base.Runtime.Exception.html ) as mentioned in this article https://www.essentialobjects.com/doc/common/collect_logs.html#code

eo_support
Posted: Friday, June 23, 2023 11:49:23 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi,

It is recommended to always use GetLogs to capture the log if possible. For GetLogs there are two separate cases:

1. When an exception occurred in your own thread (for example, when you call HtmlToPdf.ConvertHtml), the exception will be catchable by your code. Inside your exception handler you can call GetLogs to collect the log. Specifcally, in this case EO.Base.Runtime.Exception will NOT be triggered;

2. When an exception occurred in one of our internal thread, EO.Base.Runtime.Exception will be triggered. If you handle that event, then it is recommended that you call GetLogs to collect the log. If you do not handle that event, then the default handler will call GetLogs and display the result in an exception dialog, you can copy and save the result if needed;

It is NOT recommended to call CaptureDump in production due to negative performance impact.

Hope this clears up. Please feel free to let us know if you still have any questions.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.