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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:33:18+00:00 2026-05-19T02:33:18+00:00

From java.util.logging.Logger : Logger names can be arbitrary strings, but they should normally be

  • 0

From java.util.logging.Logger:

Logger names can be arbitrary strings, but they should normally be based on the package name or class name of the logged component, such as java.net or javax.swing

Could anyone explain this sentence to me ?

  • 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-19T02:33:19+00:00Added an answer on May 19, 2026 at 2:33 am

    Logger names can be arbitrary strings, but they should normally be based on the package name or class name of the logged component, such as java.net or javax.swing”

    “Logger names can be arbitrary strings …”:

    public class Foo {
        private static final Logger logger = Logger.getLogger("specify logger name here - you can use any logger name you want, even supercalifragilisticexpialidocious");
    }
    

    Any code that wants the same logger instance just has to specify the same logger name (good luck spelling “supercalifragilisticexpialidocious” the same way twice).

    However, you might want to share loggers more easily, get a handle to a specific class’ logger for configuration, or have a hierachical relationship between loggers (e.g. organize loggers to into parents and children). Classes and packages are already organized hierarchically, so they recommend that logger names:

    “… should normally be based on the package name or class name of the logged component …”

    package com.example.stackoverflow;
    
    public class Foo {
        private static final Logger logger = Logger.getLogger("com.example.stackoverflow.Foo");
    }
    

    Now I can easily get a handle to any logger for any class from anywhere (I just need to know its fully qualified class name). Also, now the the Logger framework can see which loggers are related to which, e.g. that the logger for “com.example.stackoverflow” is the parent of the logger for “com.example.stackoverflow.Foo”.

    But what if the package name changes or your class name changes? This code below does exactly the same thing as the code above, but in a less redundant and more maintainable manner:

    package com.example.stackoverflow;
    
    public class Foo {
        private static final Logger logger = Logger.getLogger(Foo.class.getName());
    }
    

    Now if the package changes, the logger name is handled automatically. If the class is renamed in an IDE, the IDE will likely notice the Foo.class literal in the getLogger call above and update the Foo.class literal accordingly.

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

Sidebar

Related Questions

I wanted to add more methods to the Calendar from java.util.Calendar, but I'm having
We're recently switched over to Log4J from JUL (java.util.Logging) because I wanted to add
I am currently using Logger from Java.Util, The default behavior for logger.info is like
I am trying to read a single file from a java.util.zip.ZipInputStream , and copy
I'm trying to change default firstDayOfWeek for java.util.Calendar from SUNDAY to MONDAY. Is it
On a JSTL/JSP page, I have a java.util.Date object from my application. I need
When launching a process from Java, both stderr and stdout can block on output
How can I write from Java to the Windows Event Log?
How do I set environment variables from Java? I see that I can do
I have a stupid java logging problem: I'm loading the logging configuration from my

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.