如何让 Perl 错误显示在 Azure 中?
How do I get Perl errors to display in Azure?
问题:
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!" 后停止(不显示 "End of script" 和 "This is a test")。
"This is a test" 未在 /LogFiles 目录中的任何日志文件中找到。
我已经验证的事情
Strawberry Perl 运行s 当通过命令行(使用 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 环境中生成的错误以便对其进行故障排除。
通过调整 *.pl 扩展名的处理程序映射的附加参数,可以将错误发送到浏览器。
特别是,-MFCGI::IIS=eval
对我有用。
请注意,浏览器中仍未报告某些错误。例如,DBI 数据库调用似乎存在问题,导致进程停止而不显示错误消息。
可以使用失败请求跟踪查看这些错误。
可以在所有设置 -> 诊断日志 -> 失败请求跟踪下启用失败请求跟踪
生成的日志可通过 FTP 在 /LogFiles/W3SVC*/fr*.xml 访问。
要查看文件,请根据您的要求下载 XML 文件,并从同一目录下载 freb.xsl。然后,您可以在 XML 查看器(例如 Internet Explorer)中查看日志 XML 文件。
更多信息:
问题:
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!" 后停止(不显示 "End of script" 和 "This is a test")。
"This is a test" 未在 /LogFiles 目录中的任何日志文件中找到。
我已经验证的事情
Strawberry Perl 运行s 当通过命令行(使用 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 环境中生成的错误以便对其进行故障排除。
通过调整 *.pl 扩展名的处理程序映射的附加参数,可以将错误发送到浏览器。
特别是,-MFCGI::IIS=eval
对我有用。
请注意,浏览器中仍未报告某些错误。例如,DBI 数据库调用似乎存在问题,导致进程停止而不显示错误消息。
可以使用失败请求跟踪查看这些错误。
可以在所有设置 -> 诊断日志 -> 失败请求跟踪下启用失败请求跟踪
生成的日志可通过 FTP 在 /LogFiles/W3SVC*/fr*.xml 访问。
要查看文件,请根据您的要求下载 XML 文件,并从同一目录下载 freb.xsl。然后,您可以在 XML 查看器(例如 Internet Explorer)中查看日志 XML 文件。
更多信息: