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 9243587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:50:25+00:00 2026-06-18T08:50:25+00:00

How can log4j be configured for MyBatis in a JUnit run configuration on Eclipse

  • 0

How can log4j be configured for MyBatis in a JUnit run configuration on Eclipse?

There are several such questions on SO and the internet. But, most of the suggestions don’t seem to work for me.

Specifically, the following doesn’t seem to work: (from the MyBatis logging page)

  1. log4j-1.2.16.jar is on my Eclipse’s Java Build Path Libraries (under Maven Dependencies).
  2. log4j.properties is on my Run Configuration. It’s under VM arguments as: -Dlog4j.configuration=C:\log4j.properties
  3. My log4j.properties file contains the below code.

log4j.rootLogger=ERROR, stdout
log4j.logger.org.mybatis.example.BlogMapper=TRACE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

As per my understanding, things will work if I can keep the log4j.properties file on the Eclipse classpath. But, I’m not sure if the run configuration VM arguments sets the classpath.

EDIT

If I force MyBatis to use log4j,

org.apache.ibatis.logging.LogFactory.useLog4JLogging();

The following is output on the console:

log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
  • 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-06-18T08:50:26+00:00Added an answer on June 18, 2026 at 8:50 am

    Got the answer:
    http://mybatis-user.963551.n3.nabble.com/log4j-for-MyBatis-in-a-JUnit-run-configuration-on-Eclipse-tp4026384p4026393.html

    An alternate way to set the classpath is as described in the answer by @sivaprasadreddy.k

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

Sidebar

Related Questions

I configured log4j SMTPAppender to send emails to me on errors. It works, but
I'm trying to run this example , but I have some problems with configuration.
In Log4j, there is a feature wherein the system can be initialized to do
I've found a lot of articles/questions dealing with this problem, but there was no
I configured the jboss-log4j.xml as you can see at the example. The problem is
Can we able to create two instance of log4j in class one to write
When using log4j, the Logger.log(Priority p, Object message) method is available and can be
I have a spring application that has configured log4j (via xml) and that runs
If my log4j.properties looks this # General configuration log4j.rootLogger = ERROR, ConsoleAppender # Appender
I'm writing a custom log4j appender, and I want to rely on another configured

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.