Skip to main content
How To

Check the Log4j Version in Ubuntu

Want to see which log4j version are you using? Here's how to check log4j version in Ubuntu command line.

Sagar Sharma

The log4j is a well-known java-based tool to log errors in applications.

But sadly, you won't find any man page or help for log4j. So, how do you determine log4j version?

Well, the easiest way to check the installed version is to use the apt command:

sudo apt list -a liblog4j2-java
check the installed version of Log4j in ubuntu using the apt

And as you can see, I'm running Log4j version 2.17.1-1.

Want to know more ways of doing so? Here you have it.

Check the installed version of Log4j on Ubuntu

In this guide, I will be sharing two more ways to check Apache log4j in Linux:

  • Using the find command
  • Using the dpkg command

So let's start with the easy one.

Use the dpkg command to check the installed version of Log4j

While you can use the dpkg command to install packages, it can also be used to find and get information about the installed packages on your system.

To list the installed package with dpkg, you will have to use the -l flag. But it will list every package of your system.

So in that case, you can use the grep command to filter the output as shown:

dpkg -l | grep log4j
find the installed version of Log4j in ubuntu using the dpkg command

Use the find command to check the installed version of Log4j

As everything is a file in Linux, you can use the find command to look for anything.

As I'm looking for a file with a specific name, I will be using the -name flag with the find command.

Here, I'm looking for a package named log4j-core with .jar extension as it will give you version info with less hassle:

find / -name log4j-core-*.jar 2>/dev/null
check the installed version of log4j in ubuntu using the find command

In the above image, the highlighted number part indicates the version of Log4j.

The reason why I used 2>/dev/null:

  • 2 indicates standard error. Which includes messages such as permission denied.
  • > is a redirection of output.
  • /dev/null is where I redirected the output.

In simple terms, I have redirected messages containing errors to the /dev/null.

The /dev/null is considered a black hole in Linux. Whatever is sent there, can't be recovered.

You can learn more about the /dev/null by the given guide:

What is /dev/null in Linux?
/dev/null is the blackhole equivalent of Linux systems. What is it and why it used?

Wrapping Up

This was a quick guide on how you can check the installed version of log4j with various methods.

Choose the one which suits you better.

And if you have any recommendations for me, feel free to let me know in the comments.

Sagar Sharma