Hot answers tagged

9

Edit 2 I came up with a far far far better approach after a little brainstorming. I'll keep my old answer here but you should probably just use the first snipped. In your main Pluginfile.php public static function log($message){ Craft::getLogger()->log($message, \yii\log\Logger::LEVEL_INFO, 'your-plugin-handle'); } public function init(){ $...


7

Another perhaps simpler approach is to write to your own log file without using the Craft logger at all. $file = Craft::getAlias('@storage/logs/pluginhandle.log'); $log = date('Y-m-d H:i:s').' '.$message."\n"; \craft\helpers\FileHelper::writeToFile($file, $log, ['append' => true]); UPDATE: This logic has been put into a helper class for modules and ...


7

Turn devMode on https://craftcms.com/support/dev-mode If you want the errors to log regardless of devMode or not, pass in true as the third parameter, e.g.: Craft::log("There was an error", LogLevel::Info, true); https://straightupcraft.com/articles/how-do-i-log-errors-warnings-and-info-in-my-plugins-to-a-craft-log-file


6

Passing true as the second parameter to print_r returns a string that can be written to the log. Plugin::log(print_r(array('test'), true));


4

Craft will automatically 'rotate' logs into new files as each current file reaches the maximum size (~1MB). This is why, if you look in /craft/storage/runtime/logs, you may see craft.log, craft.1.log, craft.2.log, etc. (I think Craft keeps a max of 5 files around before rotating them off into the ether.) At present, the max size, naming convention, and ...


4

Pretty sure you'd need to write a plugin that has a class that extends Yii's CLogRoute and override the processLogs method with your own logic. Something like this: class StdErrRoute extends \CLogRoute { public function processLogs($logs) { $strErr = fopen("php://stderr", "w"); foreach($logs as $log) { fwrite($...


4

Based on the official documentation the log files are under /storage/logs and look for the web.log file especially. If you don't find anything check your webserver logs.


3

As someone who theoretically might inherit your site one day... and also as future-you trying to diagnose a problem... please don't try to limit what Craft logs. If you want a quicker way to look for critical problems, check out the Yii2 Debug Toolbar as discussed here Profiling your Website with Craft CMS 3’s Debug Toolbar You can use it to very quickly and ...


3

So what I do is I just redirect anything requesting a WordPress-ish thing to WordPress.com (that's what they are looking for, after all...). You can see how to do that here if you're using Nginx: https://github.com/nystudio107/nginx-craft/blob/master/sites-available/somedomain.com.conf#L67


3

These are very likely bots that are scanning the website for various things (I see it for WordPress logins a ton). Two things you can do: Redirect them. This is what I do for WordPress bots Install the Retour plugin to get a better overview of what 404 errors happen on your site.


3

Something like this should work for you: Plugin::log(\CVarDumper::dumpAsString(array('test')), LogLevel::Error); Note the \ in front of CVarDumper to tell PHP that class is not in the Craft namespace, but in the global one.


2

It looks like the database schema (at Craft version 2.6.2773) is ahead of the craft/app files on your file system (at Craft version 2.5.2763). Since (I assume) you're not seeing any update info being logged in production around 2016-03-09 22:07:49 (from the dateUpdated column in the craft_info table), my guess is that someone updated the site/database ...


2

I solved it. I needed to remove calls to 'server' and 'http' in my enginx_app.conf file. Now the file only makes calls to 'location'.


2

I think to solve your issue we're going to need a bit more of information. A couple of things you can try: set a higher max execution time. I think normally the max execution time is 120 sec. and this sometimes blocks other transforms try using the craft task manager plugin to remove any tasks that get stuck. try reindexing the images, remove all the ...


2

It seems to be failing because of the date time '-0001-11-30 00:00:00', which doesn't look like a proper date to me. Did you do the database dump via the Craft CMS control Panel (CP), or did you use something else like PhpMyAdmin or Sequel Pro or something? There might be something in the way you made the export that is incompatible with your lab database?...


2

You can try installing the Retour plugin to get a log of all of the 404 errors and their referrers, and potentially handle them via redirects.


2

If you want to view the logs in the control panel in Craft 3, like was possible in Craft 2, then you will need to use this plugin: Logs


2

Adding this for posterity, for any future-traveller who happens to come along. Here's everything you need to know about making a custom logger for Craft CMS: Creating a Custom Logger for Craft CMS And then once you have a log file, you need to know how to read it: Zen and the Art of Craft CMS Log File Reading Godspeed, future traveller!


2

Put the force parameter to true MyPlugin::log("Errors:\n\n" . print_r($fieldsData, true), LogLevel::Error, true); Custom Log in Craft


1

There are a bunch of Yii 2 log parsers and integrations with 3rd party logging services you could use https://packagist.org/?query=yii2%20log such as Graylog, Papertrail, Logstash, etc.


1

Looks like that article needs to be updated for Craft 3. In Craft 3, the logs folder is at storage/logs and you can search for [error] and find the one related to email sending.


1

We were having the same issue. Our logs were getting so dense with SQL statements that it was hard to find our errors. And for the most part, seeing Craft's internal SQL would not help us debug the problem. What we've found is we can use the onelogger plugin. After installing it, we just needed to add a file called onelogger.php to our config file. This ...


1

This will be a similar answer as here: Craft 3 large log file sizes Basically Craft goes with Yii's default FileTarget settings, which is 5 log files of 10MB each before they start rotating out. Those are individual limits for both web.log and console.log files. If you want to change those behaviors you'll need to modify those properties via a config/app....


1

Craft goes with Yii 2's defaults in the FileTarget class, which is 10MB for a log file before rotating. https://www.yiiframework.com/doc/api/2.0/yii-log-filetarget#$maxFileSize-detail You can overwrite that behavior from your config/app.php file by using something like: 'components' => [ 'log' => function() { $log = Craft::...


1

Craft only stores minimum audit information in the database... mainly just when a row was created and last updated. If you're on Craft 2, there is a deprecated Audit Log plugin which might do what you're looking for. I don't think the author has intentions of porting it to Craft 3, but there is a commercial plugin called Audit that is in the Craft Plugin ...


1

We've done the redirect route in Andrew's answer before and while it keeps some script kiddies out, it can also cause less "savvy" ones to think you actually have a valid WP installation and continue to hit you as well, which doesn't really solve the issue. nginx is so efficient that we were using a few MBps in our outgoing bandwidth just to redirect a ...


1

TemplateController is what all template requests in Craft get routed through. That error just means that someone/something is trying to load a resource (in your case yoursite.com/fonts/BlissBold-webfont.ttf) and that doesn't exist on your file system and Craft has no idea how to resolve that request, so it issues a 404 Not Found in response. It's more of ...


1

I'd suggest reading over the Stuck Tasks support article. It has general debugging tips for all tasks for figuring out why they get stuck and more specifically debugging tips for the Generate Pending Transforms task. I don't know if stuck tasks also prevent the execution of pending tasks? Yes, a stuck task will prevent any other tasks created after it ...


1

I'm only 80% confident in this answer, but I'm pretty sure that runtime PHP ini_set calls won't work with nginx running with FastCGI (which is what Craft uses to change the error_log path. Try setting that path directly in your /etc/php5/fpm/php.ini file.


1

Depending on what you want to do with the logs, if you're on a *nix server, logrotate is built into most systems. Do something like: /home/*user*/craft/storage/runtime/logs/*.log { weekly dateext compress delaycompress notifempty } ... which would rotate and gzip the logs after a week and append the date. There's a billion options in there ...


Only top voted, non community-wiki answers of a minimum length are eligible