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

  • Home
  • SEARCH
  • 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 6719611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:06:47+00:00 2026-05-26T09:06:47+00:00

I am having trouble establishing the exact difference between using those two log4j conversion

  • 0

I am having trouble establishing the exact difference between using those two log4j conversion characters when used in a log4j PatternLayout (log4j patternLayout)

  • category (%c)
  • class (%C)

Can someone please give me an example where those two would be different?

Doesn’t the category always match the class name?

Regards,

  • 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-26T09:06:48+00:00Added an answer on May 26, 2026 at 9:06 am

    It will be the same if you initialize the logger in the popular way suggested by the documentation, and use it inside the X class:

    Logger logger = Logger.getLogger(com.foo.X.class);
    

    then you’ll get the same for %c and %C, because logger name (constructed by “com.foo.X.class.getName()”) would match the class name where a logging statement was issued.

    Call your logger “something”

    Logger logger = Logger.getLogger("something");
    

    and you’ll have “something” for %c and the class name for %C.

    Note that %C is computed by log4j out of the current thread’s stack trace, so it carries big performance impact, unlike %c, which is simply a String. You can conduct an interesting experiment to validate it:

    package com.foo;
    
    class A {
         private Logger = Logger.getLogger(B.class);
         // ...
         logger.log("inside A class");
    }
    

    The output for pattern [%c][%m] assuming B is in package com.foo will be:

    [com.foo.B][inside A class]
    

    The output for pattern [%C][%m] regardless of the location of B will be:

    [com.foo.A][inside A class]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having trouble using a .NET COM in vb6, It compiles ok and I
I having trouble in dividing the HTML frames. I have been using the following
I'm having trouble establishing an on state for a tab of this menu. I
Im having trouble with writing coloumn names using a FlexTable in GWT my code
I'm having trouble doing anything with clojure.contrib.sql beyond establishing a connection. I have a
Having trouble when trying to create a class using another class(and 2 inner classes),
having trouble with inter-thread communication and solved it by using dummy messages all over
Having trouble with Delphi XE2 (update2) using MS SQL 2008 R2 (sp 2) or
Having trouble using libstatgrab -- I receive the following error at compile time: libstatgrabTest.cpp:16:
I´m having trouble in creating a file and export to .yaml. I´m using Google

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.