I am trying to override the terminate method in \Magento\Framework\App\Bootstrap file which I need to customise the log creation. If anyone overrides this Bootstrap file please provide the solution here.

Thanks in advance.

  • 1
    use quality patch
    – Sohel Rana
    Aug 11 at 12:38

1 Answer 1


I have used the below steps to create Bootstrap.php patch in Magento 2


Create a the duplicate file and update your required changes


To get the file difference like git diff then please use the below command

 diff -u Bootstrap.php BootstrapUpdated.php > bootstrap.patch

After that move bootstrap.patch file into your patch custom directory and remove BootstrapUpdated.php if it first patch then create own directory under Magento root and move your bootstrap.patch file into the directory.

We need to do some manual modification in patch file.this process is common for all the patch file

--- Bootstrap.php    2023-08-14 10:15:16.000000000 -0530
+++ BootstrapUpdated.php    2023-08-14 11:34:47.326054321 -0530


    diff --git a/vendor/magento/framework/App/Bootstrap.php b/vendor/magento/framework/App/Bootstrap.php
index 16d495d922..8c69e73dfb 100644
--- a/vendor/magento/framework/App/Bootstrap.php
+++ b/vendor/magento/framework/App/Bootstrap.php
@@ -435,16 +435,16 @@
         if ($this->isDeveloperMode()) {
             echo $e;
         } else {
-            $message = "An error has happened during application run. See exception log for details.\n";
+            $message = "An error has happened during application run. See exception log for details. ";

Use any random index number and use a,b in front all the path. Most important make sure your line number should be get from where the line actually updated in the original file. while doing different it should be starting line of the difference(ex: if ($this->isDeveloperMode()). line 432 from original file) . but the actual line modified from $message(line 435 from original bootstrap file).Please check the first line -/+ symbol in your diff file then update the same in @@ -xxx,xx +xxx,xx @@

Create composer.patches.json if not exist

 "patches": {   
    "magento/framework": {
      "BOOTSTRAP-LOG": "m2-patches/bootstrap-log.patch"

Next add your composer.patches.json file in composer.json file

"extra": {
        "magento-force": "override",
        "composer-exit-on-patch-failure": true,
        "patches-file": "composer.patches.json",
        "enable-patching": true

That's it!. execute composer install and do required Mageno deployment command. Hope this will help to all.

Your Answer

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

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