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

Logging variables to log file


Go to End


3 Posts   1252 Views

Avatar
Random Guy A

Community Member, 3 Posts

29 March 2017 at 1:00am

I am trying to setup a log file to send variables to it, but nothing i do is working, please can you help, i have read all i can and tried multiple solutions and still nothing, heres what i have: -

_config.php

ini_set("display_errors", 1);
ini_set("log_errors", "On");
ini_set("error_log", "log/silverstripe.log");

SS_Log::add_writer(new SS_LogFileWriter('log/silverstripe.log'), SS_Log::WARN, '>');

php class :-

public function messageTest(){
SS_Log::log("Message Log test", SS_Log::WARN);
}

The log folder is already there but the log itself isnt being created, although when an actual php warning occurs then the log is updated.

Thanks in advance for your help

Avatar
swaiba

Forum Moderator, 1899 Posts

29 March 2017 at 4:10am

you might change '>' to '<=', or something else similar as I think that looks wrong.

Avatar
Random Guy A

Community Member, 3 Posts

29 March 2017 at 4:13am

Thank you for your suggestion, unfortunately that was on the long list of things i have tried.

I got the suspicsion that it something else that is causing the problem, in the end the only way to fix it was to re build the project, i am using the same code and it works, not sure im going to get to the bottom of this one