With regards to logging in your own plugin, is there a point which could be considered "You are logging too much" For example. In a service I currently have something like this:

public function getSomeRecordsByParentId($id)
  FooPlugin::log(Craft::t("Getting all records for parent id {$id}"), LogLevel::Info);

  // .. do service logic here

  FooPlugin::log(Craft::t("Found {$recordCount} records for parent with id {$id}"), LogLevel::Info);

And then again

public function getRecordById($id)
    FooPlugin::log(Craft::log("Trying to find record with an id of {$id}"), LogLevel::Info);

    $record = FooRecord::model()->findByPk($id);

        FooPlugin::log(Craft::log("Unable to find record with id {$id}"), LogLevel::Error);
        throw new HttpException(404);

    return FooModel::populateModel($record);

I know I'm only doing two per function at the moment but when they are all called it can really start to stack up.

I guess what i'm asking is are there any real performance hits that are going to be noticeable or has anyone noticed anything from logging a lot of things?

1 Answer 1


A few things to keep in mind.

  1. LogLevel::Infois only going to be logged when devMode is enabled, so any overhead from excessive logging won't be an issue in production.

  2. Excessive logging will consume extra memory because all logging information on a given request is stored in memory and flushed to disk at the end of the request, but overall I imaging that the performance hit will be negligible.

  3. Excessive logging will cause your log files to rotate out quicker. By default Craft will cap each log file at 1MB worth of data and will start to rotate out the older files after 6MB worth of data has been hit.

  • Perfect, thank you! Commented Sep 1, 2015 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.