Download presentation
Presentation is loading. Please wait.
1
Importance of logs in custom development
2
Introduction We all know that Drupal logs most of the things. During CUSTOM DEVELOPMENT it is important to do a little brainstorming on logging and to analyze the questions like - Where, Why, Why not, When and What to log.
3
How it helps? Logging helps to maintain the bug free modules and themes longer. Easy to debug, trace and resolve the issues.
4
Is it necessary to log? It is not necessary, it depends on the module or theme that we are building but it should not be ignored.
5
Background This presentation will try to give all question`s answer.
Why we should log? Where we should log? Where we should not log? When to log or not? What to log or not?
6
Let us get started ….
7
Why we should log? Logging makes code more effective.
It helps to understand the processing of the output and program flow. It saves developers lots of time. Non technical people can also understand the program flow. Helps to monitor the system like CPU usage, execution time of a functionality, etc. Log helps to generate reports and analytics which can very useful to take business decisions.
8
Where we should log? Wherever we want ! Few examples of files are below. .php .module .inc .tpl .test .js
9
Where we should log ... With respect to path, try to put log file in easily accessible path like - Desktop, Documents, etc. It is irritating to keep log files in deeper paths. Logging format and settings are different for individual platform. Like - Acquia Dev Desktop
10
Where we should not log? In the large loops
In the hooks or functions which are called multiple times like hook_init in D7. Avoid heavy logging during bootstrapping mode of Drupal, It can slow down Drupal.
11
Where we should not log? ... Logging is not possible in all the plain files like .info, .css, .txt, etc.
12
When to log or not? During big calculations During page loads
During ajax calls During site visit During login and logout Avoid logs if data is too heavy.
13
What to log or not? There is no restriction in logging of any type data, every type of data collection can be logged in Drupal. Criticality of data decides that it should be logged or not. Use PHP`s error_log to log every possible data collection.
14
Logging functions Watchdog ( < D8 ) \Drupal::logger in ( D8 )
PHP`s error_log
15
Important contrib modules
Export logs
16
Important Note Keep only critical loggings in production environment. It should be as small as possible. and rest of the loggings should be limited to development environment. Log statements may be removed or commented before deployment to production. It also depends on the application whether it wants to maintain a detailed log or not.
17
Important Note ... Try to keep log messages small.
Large log messages are difficult to understand and to go through. It is better to maintain the logs file to know the behavior of the application for a period of time. Failure, info, warning, status logs are equally important like success. Over a period of time logs should be cleared. A log file should not be too big to open in editor.
18
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.