✕
Forbes India Leader Recognition
e.preventDefault(); // Prevent form submission input.blur(); // remove focus input.value = ""; // optional: clear the input

Log4PHP with CodeIgniter

Log4PHP with CodeIgniter

Featured Image

You developed that fancy CI website but time and again an ugly notice/error message is displayed which annoys client. As a developer, you know that these messages are harmless but you still want to keep an eye on them and hence do NOT want to suppress them in php.ini. You can use log4php to achieve this objective where you still have access to all the logs but clients do not see them. Please follow the steps below:

1- To use log4php inside your project, you have to download the log4php with CI from the following link

https://github.com/fukata/ci-log4php (You can use SVNGit or simply download it in zip format)

Lets say you extracted the zipped code inside a folder named fukata-ci-log4php
2- Then place fukata-ci-log4php/ci_log4php folder inside the third_party folder.

 /application/third_party/ci_log4php/ (note it is _ and not -)

3- Move the MY_Log.php file from the fukata-ci-log4php/ci_app/application/libraries inside the libraries folder of your application. If you have subclass_prefix specified as APP_ in the config.php of your application, you would have to rename this file as APP_Log.php

 /application/libraries/APP_Log.php

4- Move the fukata-ci-log4php/ci_app/application/helpers/log4php_helper.php which is the helper class of log4php, inside the helpers folder of your application

 /application/helpers/log4php_helper.php

5- Create a log folder named as logs to store all logs at the time of execution. You can create it right inside application folder.
6- Move log4php.properties file from fukata-ci-log4php/ci_app/application/config/ inside your application/config folder. In this file, specify the folder path and do not change anything, unless you know what you are doing 🙂

log4php.appender.default.file = C:/xampp/htdocs/spiderman/application/logs/%s.log

7- Now we edit log_threshold inside your application/config/config.php

 $config['log_threshold'] = 4;

Below is the list of all the log_threshold values and their meanings:

If you have enabled error logging, you can set an error threshold to
determine what gets logged. Threshold options are:
     0 = Disables logging, Error logging TURNED OFF
     1 = Error Messages (including PHP errors)
     2 = Debug Messages
     3 = Informational Messages
     4 = All Messages


Now, how to use this feature inside your project
To use log4php you have to write a line in your controller

 error_reporting(0); //This would ensure that all the errors are not displayed on screen and are instead directed to log4php

Related Posts

Latest Posts

  • All Posts
  • AI Powered Knowledge
  • ai/ml
  • CEO India Magazine
  • CMMI level 5 Certification
  • e-learning
  • Fintech
  • gaming
  • Generative AI
  • healthcare
  • manufacturing
  • News
  • OTT
  • Portfolio
  • supply chain
  • travel and hospitality
  • Tudip's AI Hackathon
  • Voxlearn Enterprises
    •   Back
    • Android
    • iOS
    • Java
    • PHP
    • MEAN
    • Ruby
    • DotNet
    • IoT
    • Cloud
    • Testing
    • Roku
    • CMS
    • Python
Artificial Intelligence in Healthcare

Artificial Intelligence in Healthcare

September 23, 2026

Explore how artificial intelligence in healthcare is transforming clinical decision-making, and patient care .

Read More
AI in Manufacturing: Machine Intelligence  Meets Industrial Innovation

AI in Manufacturing: Machine Intelligence Meets Industrial Innovation

September 23, 2026

Explore how AI is transforming manufacturing through predictive maintenance, intelligent quality control, data-driven operations.

Read More
Artificial Intelligence in Manufacturing: Enabling Intelligent, Flexible and Cost-Effective Production Through AI

Artificial Intelligence in Manufacturing: Enabling Intelligent, Flexible and Cost-Effective Production Through AI

September 23, 2026

Discover how AI is transforming manufacturing through intelligent automation.

Read More

India

Plot No. 11/2, Phase 3, Hinjewadi Rajiv Gandhi Infotech Park, Pune, India – 411057.
info@tudip.com
+91-96-8990-0537

United States

1999 S. Bascom Ave Suite 700, Campbell CA. 95008, USA.
info@tudip.com
+1-408-216-8162

Canada

64 Caracas Road North York, Toronto Ontario M2K 1B1, Canada.
info@tudip.com

Mexico

Calle Amado Nervo #785 Interior B Colonia Ladron De Guevara 44600 Guadalajara, Jalisco, Mexico.
info@tudip.com

Singapore

77 High Street, #10-12B High Street Plaza, Singapore 179433.
info@tudip.com

Colombia

Cra. 9 # 113-53 Of. 1405 Bogotá D.C., Colombia.
info@tudip.com

UAE

Tudip Information Technologies L.L.C Office No 109, ABU HAIL BUILDING 13, Abu Hail, Dubai, UAE.
info@tudip.com

Nigeria

22 Kumasi Crescent, Wuse 2, Abuja, Nigeria.
info@tudip.com