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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:34:09+00:00 2026-06-14T15:34:09+00:00

I have a log4j logger that I instantiate like this: logger = Logger.getLogger(EQUIP( +

  • 0

I have a log4j logger that I instantiate like this:

logger = Logger.getLogger("EQUIP(" + id + ")");

Doing so, when I call logger.info("message"), I should get an output like this (with some date formatting):

13/11/12 15:08:27 INFO: EQUIP(1): message

But I’m only getting:

13/11/12 15:08:27 INFO: message

I’m also printing logger.getName() to the console for debugging and it gives me back the correct “EQUIP(1)” name. This behaviour is happening in some cases in my program, where I have several loggers like this, but mostly in this specific class. I want to know if I’m doing something wrong, if this name should be only the class/package name, or if it can be anything (it works well in 80+% of my loggers). I need to print the ID of each equipment because I have several of them working simultaneous, and tracking them without this would be next to impossible.

How should I fix this, preferably without resourcing to changing all my log calls to include this prefix?

  • 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-14T15:34:11+00:00Added an answer on June 14, 2026 at 3:34 pm

    The output format depends on the pattern you’ve configured for the appender. If the pattern string includes %c then you’ll get the logger name included, if it doesn’t then you won’t.

    An alternative approach might be to use the mapped diagnostic context, which is designed to disambiguate between log output from different threads writing to the same logger.

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

Sidebar

Related Questions

I have a java app that uses log4j. Config: log4j.rootLogger=info, file log4j.appender.file=org.apache.log4j.DailyRollingFileAppender log4j.appender.file.File=${user.home}/logs/app.log log4j.appender.file.layout=org.apache.log4j.PatternLayout
I have a log4j properties something like below. Everything that is logged in TextProcessor.log
If I have a log4j logger in a class that implements Runnable: MyTask implements
My log4j.properties file looks like this: # Root logger option log4j.rootLogger=DEBUG, file # Direct
I would like to have two different log4j loggers in my application, and for
I have a spring application that has configured log4j (via xml) and that runs
I have used Log4j and JDK Logger both for logging purpose, so i find
I have a spring bean that I have configured in applicationContext like below: <bean
I have a web app that uses Spring's Log4jConfigurer class to initialize my Log4J
In my log4j.properties I have: log4j.rootLogger=DEBUG,stdout log4j.logger.notRootLogger=DEBUG,somewhereelse The appenders stdout and somewhereelse are both

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.