Application Level Log Collection

Ata Erdemir
5 min readNov 1, 2023

--

Effective application level log collection is a crucial component of maintaining system health, diagnosing issues, and enhancing overall performance, and as most important as you know is governance and regulations. In this blog post, we will explore the importance of collecting and managing application logs and the best practices to ensure a seamless process.

Collecting logs at the application level is crucial for monitoring, debugging, and troubleshooting your software. In addition, during the audit periods, when the auditor asks for application data logs, you must give the all related logs that where questioned by the auditor.

Logging helps you record relevant information about your application’s behavior and the interactions it has with its environment. Here’s a general guide on how to collect logs at the application level:

Choose a Logging Framework/Tool

  • Logging Libraries: Many programming languages provide built-in or third-party logging libraries, such as log4j for Java, Python’s built-in logging module, or Serilog for .NET.
  • Logging as a Service: Consider using cloud-based logging services like Amazon CloudWatch, Azure Application Insights, or third-party solutions like Loggly, Papertrail, or Splunk.

At this point, if you are working a finance organization, must move toward an enterprise solution. As a nature of today’s organizations are using SIEM solutions such as QRADAR, ArcSight, SPLUNK, etc. In general SoC departments use such products. However, governance policy and government regulations are forcing organizations to collect more specific logs day by day.

Define Logging Levels

Determine the logging levels that you need. Common levels include INFO, DEBUG, WARNING, ERROR, and FATAL. Different levels are used to log different types of events, from informational messages to critical errors. However, most regulations nowadays require some basic specific logs for auditing.

Log Relevant Information

Log relevant information about your application’s behavior, including:

  • Timestamp: Include a timestamp in each log entry to track when the event occurred.
  • Log Level: Specify the severity of the log entry (e.g., INFO, ERROR).
  • Message: Describe the event or action that is being logged.
  • Contextual Data: Include any relevant data that helps in diagnosing issues. This could be user IDs, request IDs, or any other contextual information.
  • Stack Traces: For errors and exceptions, include stack traces to pinpoint the source of the problem.
  • Custom Fields: Add custom fields as needed for your specific application.

Log content required in Türkiye Banking regulation:

  • Date, time, and time zone information when the record was created.
  • Information showing what the change was, together with the transaction or event that created the record.
  • Information indicating the individual user or system to which the record is associated.

Information system components create logs that are listed above with no exception if they not services for any specific purpose. Thus, the principle of information assurance is fulfilled.

https://www.techtarget.com/searchsecurity/definition/nonrepudiation

In theory, everything was perfect till this step. We know what kind of steps should be taken to get Application logs. We define a “Framework” that we’ll use. We decide what kind of product or solution we will use during the log collection, we know what kind of logs are produced by applications and we know what kind of logs we should collect and show the auditors in case. However, some additional questions will pop up in our minds. Who’s going to manage how those logs are managed and how those logs will be analyzed? Let’s see.

Centralized Logging

https://www.secuinfra.com/en/solutions/centralized-log-management/

Consider centralizing your logs in a dedicated log storage or analysis system. This makes it easier to search and analyze logs, especially in distributed systems. Use the appropriate logging transport or handler for your chosen logging framework to send logs to the centralized location.

Log Rotation and Retention

https://media.istockphoto.com/id/1141641174/photo/air-traffic-controller-signaling.jpg?s=612x612&w=0&k=20&c=tbQiMrG6wIP0gYk6h8vOa9eS2YSY8RRWdVPUsLaAahY=

Configure log rotation and retention policies to manage log file sizes and ensure that logs are retained for an appropriate period. This prevents log files from consuming too much storage. In this section, according to the architecture of a company’s information system, different solutions may be required to fulfill needs. There are two main ways to collect logs from the data source: with agent & agentless. There are pros and cons for both, such as performance and maintenance issues, etc.

Alerting and Monitoring

https://www.flaticon.com/free-icon/alert_1022476

Set up alerts for critical error logs, security breaches, anomalies, and other important events. Monitoring tools can help you proactively detect and address issues before they impact users. Also, you can feed the teams for specific needs by creating alerts according to the team’s related.

Secure Logging

Ensure that sensitive data (e.g., passwords, API keys) is not logged in clear text. Use log masking or scrubbing to protect sensitive information. In case, you provide a log to the auditor or another related teams, you may require masked sensitive data before reporting.

Testing and Validation

Before you get logs into your centralized log management tool, you should test your logging implementation to ensure it’s working as expected. Choose an example log that you will get to the tool and manually inspect logs during testing and use automated testing to validate log content and behavior.

Documentation

Document your logging conventions and practices, including log levels, when to use them, and how to interpret log messages. Most of the technical personnel do not like creating documents. However, documents provide rich resources for newcomers after you.

Conclusion

Log collection at the application level is an essential practice for software development, aiding in monitoring, debugging, and troubleshooting while also playing a pivotal role in compliance with governance and regulations. To establish a robust logging system, select an appropriate framework or tool, define logging levels, log relevant information in alignment with data privacy regulations, centralize logs for easier management, set up log rotation and retention policies to comply with data retention rules, implement alerting and monitoring for regulatory compliance, secure sensitive data in logs to meet privacy and security standards, thoroughly test your logging, document logging practices to ensure adherence to governance requirements, and continually refine your approach to meet evolving regulatory demands. By doing so, you not only enhance your ability to identify issues and gain insights into user behavior but also ensure that your application remains compliant with relevant governance and regulatory mandates, reducing legal and security risks.

--

--

Ata Erdemir
Ata Erdemir

Written by Ata Erdemir

An ordinary security guy and coffee addicted!

No responses yet