Skip to main content

How to Check Logs or Journal of a Specific Service on Linux


Monitoring logs is an essential part of system administration. On Linux, logs help diagnose issues and track service behavior. This guide covers various ways to check logs for a specific service.

Using journalctl for Systemd Services

Most modern Linux distributions use systemd, and logs are stored in the journal. To view logs for a specific service, use:

journalctl -u service-name.service

Example for Nginx:

journalctl -u nginx.service

Viewing Real-Time Logs

To follow logs in real time, use:

journalctl -u service-name.service -f

This is similar to tail -f for traditional log files.

Checking Logs with a Time Filter

To see logs from the last 1 hour:

journalctl -u service-name.service --since "1 hour ago"

For logs between two timestamps:

journalctl -u service-name.service --since "2024-02-01 10:00" --until "2024-02-01 12:00"

Using Traditional Log Files

Some services log to files in /var/log/. Check:

ls /var/log/

For example, Nginx logs are usually found at:

/var/log/nginx/access.log
/var/log/nginx/error.log

To view logs with tail:

tail -f /var/log/nginx/error.log

Conclusion

Using journalctl is the preferred way to check logs for systemd-managed services, while traditional logs can be found in /var/log/. Mastering these commands will help you efficiently troubleshoot and monitor Linux services.

Comments

Popular posts from this blog

HOW TO WRITE, COMPILE AND RUN C++ CODE ON LINUX KALI

Developing a C++ Program on Kali Linux Without Installing Additional Software This article is for hackers who want to develop a C++ program on Kali Linux without installing any additional software. Some might say you need to install a separate compiler or extra tools to write and run a simple C++ program on Kali Linux. However, I’ll show you how to do it right out of the box. Pre-installed C++ Compiler in Kali Linux Kali Linux comes with a pre-installed C++ compiler called g++ . We will use this to write and compile a basic "Hello, World!" program. Step 1: Check if g++ is Installed Open your terminal and run the following command: g++ -v If the compiler is installed, you should see version details. If not, you will get an error message. Step 2: Create a C++ File In your terminal, type: nano MyCpp.cpp This will create a C++ file and open it in the Nano editor. Step 3: Write the C++ Code Once Nano opens, enter the following C++ code: #include <...

LOAN MANAGEMENT SYSTEM (My Project Idea)

There are many companies that specializes on giving loan to people; they make their profits by collecting interest on any money they lend out, and before a loan can be given to any customer, the customer must provide a collateral and some details such as:  contact details and a reference/guarantor. When the loan is finally given to the customer, they charge interest based on the the amount given to the customer for a given period of time which could be daily, weekly, monthly or yearly.  For example, a company could be collecting interest based on a particular amount for a given period of time like: $200,000 loan would have an interest tag of $2,000  per month until the money is returned, and $100,000 would have an interest of $1,000 per month until the money is returned.  In  addition, the customers need to know when the time for them to pay their interest comes e.g.  at the end of the month or the timing model with which the calculation is being made. Usua...

HOW TO MAKE A SIMPLE TEXT TO SPEECH(TTS) WINDOWS PROGRAM USING C# PROGRAMMING LANGUAGE.

This post is a beginner's guide on how to get started with speech programming in visual studio using c# (c_sharp) programming language. For those who don't know what a programming language is, in a nut shell, a programming language is simply a command based computer language used for instructing a computer to do a particular job. When I say job, I mean very complex job. Write the above definition in an exam and stand a chance of losing marks. The definition isn't all there is about what programming language is, so I suggest you make a good search to learn what programming language really is. Though, this article is for beginners but I will say "BEGINNERS ARE CLASSIFIED", am a beginner. If you are a beginner who hasn't tasted code in his or her life before, I suggest you go start something. A good learning source is "tutorial point", they taught me a lot. Now for you who have tasted code, you will need the following: Computer System running wind...