Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Can't get silverstripe to log errors/show error stack


Go to End


1049 Views

Avatar
eduardoleoni

Community Member, 1 Post

10 January 2017 at 2:44pm

I'm trying to get Silverstripe to log errors but no success, this is the best I get out of it:

"Parse error: syntax error, unexpected '}' in /vagrant/website/mysite/code/Controllers/PageController.php on line 10"

Only the normal PHP error message, no framework call stack or similar!

The reason I need it is because I want to log errors to Sentry, but I can't even log it to the file system, most likely because Silverstripe's call stack isn't being triggered at all, I'm falling back to PHP's error stack.

I'm using Silverstripe 3.5, here's my _ss_environment.php:
<?php
define('SS_DATABASE_CLASS', 'MySQLPDODatabase');
define('SS_DATABASE_SERVER', 'localhost');
define('SS_DATABASE_USERNAME', 'vagrant');
define('SS_DATABASE_PASSWORD', 'vagrant');
define('SS_DATABASE_NAME', 'ccf_website');
define('SS_DATABASE_CHOOSE_NAME', false);
define('SS_DATABASE_TIMEZONE', 'NZST');

define('SS_DEFAULT_ADMIN_USERNAME', 'sadasda@assaddsa.com');
define('SS_DEFAULT_ADMIN_PASSWORD', 'dev');

define('SS_ENVIRONMENT_TYPE', 'dev');

Here's _config.php:
<?php
require_once('conf/ConfigureFromEnv.php');

global $project;
$project = 'mysite';

global $databaseConfig;
$databaseConfig = [
'type' => SS_DATABASE_CLASS,
'server' => SS_DATABASE_SERVER,
'username' => SS_DATABASE_USERNAME,
'password' => SS_DATABASE_PASSWORD,
'database' => SS_DATABASE_NAME,
'path' => ''
];

// Set the site locale
i18n::set_locale('en_US');

Security::setDefaultAdmin('eduardo@pixelfusion.co.nz', 'dev');

// log errors and warnings
SS_Log::add_writer(new SS_LogFileWriter('../silverstripe-errors.log'), SS_Log::NOTICE, '<=');