Open In App

Verifying App Server Logs to Understand the Issues in Application

Last Updated : 24 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Analyzing application server logs requires a good understanding of the application and its log formats. This article focuses on discussing server logs in detail.

What are Server Logs?

Server logs are files that record events and activities that occur on a server. These logs contain valuable information about the server’s usage, performance, errors, and other relevant data.

  1. They serve as a record of all activity associated with the server and can be used for various purposes, such as troubleshooting, performance optimization, security analysis, and auditing.
  2. Application Server Logs help you in debugging you can say it is the initial and easiest path when you want to debug an application.
server_log

Server Logs

Where are Server Log Files Located?

Log files are the files that contain a list of events or records that a computer has “logged” and include system-related information. They are a historical record of everything that happens within a system, including events such as transactions, errors, and intrusions. These are typically stored in a directory on a computer and are accessible using text editors or web browsers.

The location of application log files can vary depending on the application and the operating system. Here are some common locations where you might find application log files:

  1. For JavaScript and TypeScript applications, log files are not inherently created by the applications themselves. Instead, developers typically use the console.log() method to output messages to the console for debugging and troubleshooting purposes.
  2. In the context of Web Applications, log files are typically located on the server where the application is hosted. The specific location can vary depending on the server configuration and the logging framework used.
  3. For Android applications, log files can be viewed using tools such as Logcat within Android Studio, any Log Viewer Android app, or simply plain text. The current log is a .log file that can be accessed through these methods. Logcat Window is the place where various messages can be printed when an application runs.
Server Log Files

Logcat Window

Verifying App Server Logs to Understand the Issues in the Application

One thing to keep in mind as an application developer, you are going to develop the application, and you want to debug the application to find the cause or the issues of the application that degrade the performance of the application. Your purpose will be to find out the reason.

Step 1: Identify the information you want to log in to the console or you want to print on the logcat window

This depends on the developer, based on his requirements, and the situation of the application, he can decide what kind of information he wants to print on the console, but one thing has to be remembered that console messages or logs are for development purposes and will never be displayed to the user.

What kind of information we can display using these logs?

Using logs, developers can display various types of information for monitoring, troubleshooting, and security purposes. These include:

  • System Information: Logs can provide insights into security-related events, including failed login attempts, intrusion detection, and firewall activities, and system-related information, such as errors, warnings, and other events that occur within the application or the operating system.
  • Network Activities: Using logs, we can print the network status of the system.
  • API Responses: Using logs, we can print API request and response status, response XML or JSON files, to observe the particular data.
  • Performance Monitoring: Logs can be used to monitor system performance, including tracking errors, resource usage, and application response times.

Step 2: Keyword Determination

To use log messages effectively for debugging you need to maintain a structure of these log messages throughout your project. (There is no specific rule for this.)

Generally, the log messages look like:

log(KEYWORD, MESSAGE) or log(KEYWORD+ ” ” +MESSAGE)

  • This MESSAGE variable stands for the information you want to print, may it be static or it will some dynamic data as we discussed above.
  • So, In general case, when you try to find the particular log in the console, you can’t determine the value of the MESSAGE variable.
  • For this reason, you have to append proper KEYWORD with your message, so that later you can find it easily, and able to check that part of the application.

As we discussed previously, Console messages or logs are for development purposes, so it depends on how can you arrange those keywords for each log message, You can randomly use any keyword, but that might not be the correct way. In that case, it is possible that you and your team may create many unnecessary log messages throughout the project, which may cause the application performance issue.

Real-world Applications of Log Messages:

1. Using Console Functions:

These functions are widely used in web-based applications, allowing developers to interact with the browser’s console and log messages. The ability to accept any number of parameters and various data types makes these console functions flexible and useful for logging and debugging in web-based applications.

Following are the console functions available to display log messages.

Javascript




//console functions available to display log messages
  const KEYWORD = "KEYWORD_TO_SHOW_LOG"
  const LOG_MESSAGE = 'This is a log message'
  const WARNING_MESSAGE = 'This is a warning message'
  const INFO_MESSAGE = 'This is an information message'
  const ERROR_MESSAGE = 'This is an error message'
 
let TABLE_DATA =  [
  { name: 'Alice', age: 25, city: 'New York' },
  { name: 'Bob', age: 30, city: 'San Francisco' },
  { name: 'Charlie', age: 28, city: 'Los Angeles' }
];
  console.log(KEYWORD, LOG_MESSAGE) // It is a basic way to diagnose and troubleshoot issues in code.
  console.info(KEYWORD, INFO_MESSAGE) //To print some informational message
  console.error(KEYWORD, ERROR_MESSAGE) // To print error message
  console.warn(KEYWORD, WARNING_MESSAGE) // To print warning
  console.table(KEYWORD,TABLE_DATA)
  // The table() method is used to display tabular data as a table in the console.


These console functions can take any number of parameters. The parameters they can take include various data types such as strings, numbers, objects, arrays, and more. These functions are designed to be versatile and can accept multiple parameters of different types, allowing developers to log and display a wide range of data to the console for debugging and diagnostic purposes.

Step 3: Verify the log messages in the console

When you inspect an application in the browser, you will able to see various tab-windows (i.e. Inspect Tools) available there, for different purposes.

Screenshot-2024-01-14-172305

Chrome Browser’s Inspection Tools

1. Run the application in the browser.
2. Right click anywhere on your application in the browser.
3. Inspect the code.

Screenshot-2024-01-14-171744

Inspect The Browser

4. Go to console.
5. Search for keyword, you will able to see corresponding log messages.

Screenshot-2024-01-14-173313

Log Messages On Server

Conclusion

Delving into the depths of application server logs is vital for nurturing the system’s well-being, fine-tuning its performance, and standing guard against potential security threats. It’s akin to peering into the soul of the system, understanding its struggles, and empowering it to shine brighter.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads