In this coding ground we will create a secure logging function
Some points to remember while implementing logging & monnitoring
Do not log too much or too little. For example, make sure to always log the timestamp and identifying information including the source IP and user-id.
Pay close attention to time syncing across nodes to ensure that timestamps are consistent.
Follow a common logging format and approach within the system and across systems of an organization.
Encode and validate any dangerous characters before logging to prevent log injection attacks.
Do not log sensitive information. For example, do not log password, session ID, credit cards, or social security numbers.
Protect log integrity. An attacker may attempt to tamper with the logs. Therefore, the permission of log files and log changes audit should be considered.
Forward logs from distributed systems to a central, secure logging service. This will sure log data cannot be lost if one node is compromised. This also allows for centralized monitoring.