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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:10:53+00:00 2026-06-13T06:10:53+00:00

I am trying to use SLF4J-Log4j for the first time. In every Java class,

  • 0

I am trying to use SLF4J-Log4j for the first time. In every Java class, I define a logger like so:

private org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(<TheClass>.class);

(And of course, I make sure that the slf4-log4j12-1.6.4.jar JAR is on the classpath!)

But whenever I go to use the logger, like logger.debug("Something interesting happened"); or logger.error("An error occurred");, I don’t see their output in my log files. However, no exceptions occur and the app (its actually a WAR deployed to Tomcat) runs fine.

Here is the log4j.properties file included in the project:

# Set the root logger to DEBUG.
log4j.rootLogger=DEBUG

# MonitorLog - used to log messages in the Monitor.log file.
log4j.appender.MonitorAppender=org.apache.log4j.FileAppender
log4j.appender.MonitorAppender.File=${catalina.base}/logs/MyAppMonitor.log
log4j.appender.MonitorAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.MonitorAppender.layout.ConversionPattern= %-4r [%t] %-5p %c %x - %m%n

# Use the MonitorAppender to log all messages.
log4j.logger.*=DEBUG,MonitorAppender
org.quartz.impl.StdSchedulerFactory=DEBUG,MonitorAppender

This WAR uses Quartz to cron a few jobs, which is why you see that last entry.

When I check Tomcat’s logs/ directory, I see the MyAppMonitor.log get created, but it has nothing in it (0 bytes). I’ve scanned all the typical catalina.out, catalina-, and localhost- logs as well, and none of my log statements are seeing the light of day.

I am thinking:

  1. I don’t have log4j.properties configured right, or
  2. I don’t have slf4j-log4j configured right, or
  3. This is a classpath issue and perhaps the WAR can’t find log4j.properties (although I would imagine I would see errors or warnings for this), or
  4. I’m not using (the API itself) SLF4J correctly, or
  5. I never actually created something called MonitorAppender, so I’m wondering if this is the problem; I was just following an example I saw online

Can anybody spot where I’m going awrye, or help me troubleshoot this? Thanks in advance!

  • 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-13T06:10:54+00:00Added an answer on June 13, 2026 at 6:10 am

    Your log4j.properties configuration file is has a number of errors in it. Try with something simple like the following.

    log4j.debug=true
    log4j.rootLogger=DEBUG, CON
    
    log4j.appender.CON=org.apache.log4j.ConsoleAppender
    log4j.appender.CON.layout=org.apache.log4j.PatternLayout
    log4j.appender.CON.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
    

    As for the configuration file in your question, the root logger does not have an appender attached. Moreover, the line

    log4j.logger.*=DEBUG,MonitorAppender
    

    is not valid as ‘*’ is not supported.

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

Sidebar

Related Questions

I'm trying to use Spring to inject a SLF4J logger into a class like
I'm trying use epoch time dates in my series data. The array looks like
Im trying use a Java annotation in a Groovy class but have trouble to
I am trying use a Java Uploader in a ROR app (for its ease
Trying to use log4j's built-in JMSAppender to log messages to a local message queue
I am trying use filehelpers class builder but I am kinda confused on what
I'm trying use to selenium with firefox on CentOS from command line like this:
Trying to use an excpetion class which could provide location reference for XML parsing,
I'm trying use jquery ui tabs together with js and mvc3. <div class=demo> <div
I'm trying use jquery to remove a class from an element (not knowing ahead

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.