Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3238098
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:48:53+00:00 2026-05-17T17:48:53+00:00

I have a simple log4j.property file and a simple program that use log4j. But

  • 0

I have a simple log4j.property file and a simple program that use log4j. But when I run my jar I see only this

log4j:WARN No appenders could be found for logger (package com.mycompany.hellolog4j).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Here is how I use logger:

package com.mycompany.hellolog4j;

import java.io.File;
import java.io.IOException;
import org.apache.log4j.*;

public class SimpleLogging
{

    public static void main(String args[]) throws IOException {

        Logger logger = Logger.getLogger(SimpleLogging.class.getPackage().toString());
       // SimpleLogging demo = new SimpleLogging(rbName);
        //demo.doLogging(name);
        logger.info("printing the message...");
    }
}

And this is part of my pom.xml

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathLayoutType>custom</classpathLayoutType>
                            <mainClass>com.mycompany.hellolog4j.SimpleLogging</mainClass>
                            <customClasspathLayout>../lib/log4j.jar ../log4j.properties</customClasspathLayout>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

And here is my log4j.properties

log4j.rootLogger = DEBUG, testAppender

log4j.logger.com.mycompany.hellolog4j=DEBUG, testAppender

log4j.appender.testAppender=org.apache.log4j.ConsoleAppender

log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.testAppender.layout.conversionPattern=%p-%m%n

Now from my project directory I run jar file. This is my project directory

drwxr-xr-x 5 proger users 4096 2010-10-15 22:59 ./
drwxr-xr-x 3 proger users 4096 2010-10-15 22:27 ../
drwxr-xr-x 2 proger users 4096 2010-10-14 22:54 lib/
-rw-r--r-- 1 proger users  291 2010-10-15 23:00 log4j.properties
-rw-r--r-- 1 proger users 1689 2010-10-15 22:59 nbactions.xml
-rw-r--r-- 1 proger users 1987 2010-10-15 22:56 pom.xml
drwxr-xr-x 4 proger users 4096 2010-10-13 23:01 src/
drwxr-xr-x 6 proger users 4096 2010-10-15 22:59 target/
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:48:54+00:00Added an answer on May 17, 2026 at 5:48 pm

    Put the log4j.properties file in src/main/resources so that it is bundled into your JAR file, and thus on the classpath.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple application that illustrates the function of logging. I use
I have a simple test run of some medium-complexity code that won't terminate, i.e.
I have simple php validation form that is halfway working. If you leave the
I have simple win service, that executes few tasks periodically. How should I pass
I have a simple project with 3 dependencies but for some reason when i
I have a common jar that multiple web applications are using. All the web
I have a simple web service like this: @WebService public class MyWebService { @WebMethod
I have a simple web app running on Tomcat 5.5 with log4j for logging.
I have a Java web application that currently uses Log4J for logging. I'd like
This is a follow-up from VIM: simple steps to create syntax highlight file -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.