如果说 die/warn 在我自己的模块中,则希望将 die 和 warn 记录到文件日志(在生产模式下)。如果 die/warn 出现在 ./lib/main.pm 中,则工作正常,但如果它们出现在 MyModule 中则不会,在这种情况下不会出现 logginc。有任何想法吗?
我使用的模式是:
./lib/main.pm:
package main;
use Dancer ':syntax';
use MyModule;
...
warn 'this will get logged. hurrah!';
my $result = &MyModule::MyMethod();
./MyModule.pm:
package MyModule;
...
sub MyMethod {
warn 'this wont get logged for some reason. any idea why not?';
return 'result';
}
阿帕奇配置:
<VirtualHost *:80>
ServerName myapp.com
DocumentRoot /home/myapp/public
SetEnv DANCER_ENVIRONMENT "production"
<Directory />
SetHandler perl-script
PerlResponseHandler Plack::Handler::Apache2
PerlSetVar psgi_app /home/myapp/bin/app.pl
</Directory>
CustomLog /home/myapp/logs/access.log common
ErrorLog /home/myapp/logs/error.log
</VirtualHost>
和生产.yml:
log: "warning"
logger: "file"
log_path: "/home/myapp/logs/"
warnings: 0
show_errors: 0
route_cache: 1