如何在Azure中显示Perl错误?

时间:2016-03-08 16:13:43

标签: perl azure strawberry-perl

问题:

Perl脚本生成的错误不会在Azure Web应用程序中显示或记录。

重现步骤:

  • 使用this guide将Strawberry Perl安装到Azure Web应用程序。

    该指南中最相关的部分是我将Perl配置为.pl扩展名的处理程序,使用perl.exe参数-MFCGI::IIS=do

  • 启用日志记录到本地文件系统(错误级别:详细)。

  • 启用详细的错误消息和失败的请求跟踪。

  • 在浏览器中运行以下测试脚本:

    
    use strict;
    use warnings;
    use diagnostics;
    use CGI::Carp 'fatalsToBrowser';
    
    use CGI;
    my $q = new CGI;
    print $q->header(-type => "text/plain");
    
    print "Hello, World!\n";
    
    die "This is a test";
    
    print "End of script.";
    

我的结果:

  • 脚本在“Hello,World!”之后停止(不显示“脚本结束”和“这是测试”。)

  • 在/ LogFiles目录的任何日志文件中都找不到“这是一个测试”。

我已验证的内容

  • Strawberry Perl在通过命令行执行时运行(使用Kudu)。

  • 使用命令行运行时,脚本会生成预期结果:

    [Thu Mar 10 16:09:30 2016] azure-test.pl: This is a test at d:\home\site\wwwroot\cgi-bin\azure-test.pl line 12.
    Content-Type: text/plain; charset=ISO-8859-1
    
    Hello, World!
    <h1>Software error:</h1>
    <pre>This is a test at d:\home\site\wwwroot\cgi-bin\azure-test.pl line 12.
    </pre>
    <p>
    For help, please send mail to this site's webmaster, giving this error message 
    and the time and date of the error.
    
    </p>
    

为什么我不能只使用Perl来查看错误?

不同的代码段在Azure中失败,但在Perl中失败。我需要查看Azure环境中生成的错误,以便对其进行故障排除。

1 个答案:

答案 0 :(得分:0)

Errors can be sent to the browser by adjusting the additional arguments to the handler mapping for the *.pl extension.

In particular, -MFCGI::IIS=eval worked for me.

See the documentation.

Note that some errors still aren't reported in the browser. For example, there appears to be an issue with DBI database calls that causes the process to halt without displaying the error message.

These errors can be viewed using Failed Request Tracing.

Failed Request Tracing can be enabled under All Settings -> Diagnostic Logs -> Failed Request Tracing

The resulting logs are accessible via FTP at /LogFiles/W3SVC*/fr*.xml .

To view the files, download the XML file for your request, along with freb.xsl from the same directory. You can then view the log XML file in an XML viewer (such as Internet Explorer).

More information:

相关问题