how to create log file in PHP?
In this post, we will show you how to create log file in PHP, hear for how to create log file in PHP we will give you a demo and an example for implementation.
Here is code for create log file in PHP
$log_time = date('Y-m-d h:i:sa');
$log_msg = 'how to create log file in php?';
wh_log('************** Start Log For Day : ' . $log_time . ''**********');
wh_log($log_msg);
wh_log('************** END Log For Day : ' . $log_time . ''**********');
function wh_log($log_msg)
{
$log_filename = 'log';
if (!file_exists($log_filename))
{
// create directory/folder uploads.
mkdir($log_filename, 0777, true);
}
$log_file_data = $log_filename.'/log_' . date('d-M-Y') . '.log';
file_put_contents($log_file_data, $log_msg . '\n', FILE_APPEND);
}
What is a Log File?
A log file is an event that took place at a certain time and might have metadata that contextualizes it.
PHP Laravel 5: Class 'MongoDBDriverManager' not found
In this post we will give you information about PHP Laravel 5: Class 'MongoDBDriverManager' not found. Hear we will give you detail about PHP Laravel 5: Class 'MongoDBDriverManager' not foundAnd how to use it also give you demo for it if it is necessary.
In this post, you will find the solution for issue :.
FatalThrowableError in Client.php line 81: Class 'MongoDBDriverManager' not found
When you are going to connect MongoDB database with any PHP application then you can face this issue if you don't have PHP MongoDB driver.
So first you need to run following command to install Mongodb PHP extension in Ubuntu :
sudo apt-get install php-mongodb
Now restart the server :
sudo service apache2 restart
Try this..
Hope this code and post will helped you for implement PHP Laravel 5: Class 'MongoDBDriverManager' not found. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs
Log files are a historical record of everything and anything that happens within a system, including events such as transactions, errors, and intrusions. That data can be transmitted in different ways and can be in structured, semi-structured, and unstructured formats.
Types of Logs File?
Nearly every component in a network generates a different type of data and each component collects that data in its own log. Because of that, many types of logs exist, including:
- Event Log: a high-level log that records information about network traffic and usage, such as login attempts, failed password attempts, and application events.
- Server Log: a text document containing a record of activities related to a specific server in a specific period of time.
- System Log (syslog): a record of operating system events. It includes startup messages, system changes, unexpected shutdowns, errors and warnings, and other important processes. Windows, Linux, and macOS all generate syslogs.
- Authorization Logs and Access Logs: include a list of people or bots accessing certain applications or files.
- Change Logs: include a chronological list of changes made to an application or file.
- Availability Logs: track system performance, uptime, and availability.
- Resource Logs: provide information about connectivity issues and capacity limits.
- Threat Logs: contain information about system, file, or application traffic that matches a predefined security profile within a firewall.
Hope this code and post will help you implement log file in PHP. if you need any help or any feedback give it in the comment section or if you have a good idea about this post you can give it in the comment section. Your comment will help us to help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting posts and code Keep reading our blogs onlincode.org
