How to find the Log4j version running (with sample code)

Published on Author bloggeroneLeave a comment

To determine the version of log4j running, use the code below…

import  org.apache.log4j.Layout;
public class MyClass {
   public static void main(String[] str) {
     Package pak = Layout.class.getPackage();
     System.out.println("Title:   "+pak.getImplementationTitle());
     System.out.println("Vendor:  "+pak.getImplementationVendor());
     System.out.println("Version: "+pak.getImplementationVersion()); //this gets you the version number

This Outputs:

package org.apache.log4j
Implementation title: log4j
Implementation vendor: "Apache Software Foundation"
Implementation version: 1.2.8



Leave a Reply

Your email address will not be published. Required fields are marked *