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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:38:41+00:00 2026-06-14T02:38:41+00:00

I am trying to set the java util logging config file at runtime to

  • 0

I am trying to set the java util logging config file at runtime to avoid having to set it as a VM parameter.
But this just doesn’t work. Whenever I am trying to reread the configuration, logging is disabled at all.

See the following code snippet:

package test;

import java.io.FileInputStream;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;

public class A {
  private static final Logger LOGGER= Logger.getLogger(A.class.getName());

  public static void main(String[] args) throws Exception {
    System.out.println("--- start");
    LOGGER.log(Level.SEVERE, "SEVERE 1");
    LOGGER.log(Level.FINEST, "FINEST 1");
    LogManager.getLogManager().readConfiguration();
    LOGGER.log(Level.SEVERE, "SEVERE 2");
    LOGGER.log(Level.FINEST, "FINEST 2");
    LogManager.getLogManager().readConfiguration(new FileInputStream("/tmp/logging.properties"));
    LOGGER.log(Level.SEVERE, "SEVERE 3");
    LOGGER.log(Level.FINEST, "FINEST 3");
    System.out.println("--- end");
  }
}

This is the output if I run the class without any VM argument:

--- start
09.11.2012 09:59:25 test.A main
SCHWERWIEGEND: SEVERE 1
09.11.2012 09:59:25 test.A main
SCHWERWIEGEND: SEVERE 2
--- end

As you can see, only the SEVERE levels are logged, as this is the default of the JREs logging.properties. Calling LogManager#readConfiguration() doesn’t change anything. But when trying to read the configuration from my logging.properties, absolutely nothing is logged. There is no difference in calling LogManager#readConfiguration(InputStream) or setting the java.util.logging.config.file property and calling LogManager#readConfiguration().

Now see the next output, when I run the same code with the VM property -Djava.util.logging.config.file=/tmp/logging.properties :

--- start
2012-11-09 10:03:44.0838 SEVERE  [test.A#main()] - SEVERE 1
2012-11-09 10:03:44.0843 FINEST  [test.A#main()] - FINEST 1
--- end

As you can see, both the SEVERE and the FINEST levels are logged and they are logged in a different format. Both is specified in my custom logging.properties.
But logging stops here after calling LogManager#readConfiguration()! This is different from the example above and I don’t understand it. Also, just as in the example above, calling LogManager#readConfiguration(InputStream) doesn’t work.

So what is the problem? According to the javadoc setting the java.util.logging.config.file property at runtime should work. Also both readConfiguration() methods should work as I expect. So what is the problem?

  • 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-14T02:38:42+00:00Added an answer on June 14, 2026 at 2:38 am

    Probably a problem with your logging properties. I noticed that I had to use both level specifications in the config (root and console) to get the result.

    Maybe your root logger level is below FINEST, e.g. INFO (.level=INFO).

    Or not set at all, in which case I suppose it to be INFO.

    I ran your code with the following logging.properties:

    handlers=java.util.logging.ConsoleHandler
    .level=FINEST
    java.util.logging.ConsoleHandler.level=FINEST
    

    Without specifying the -Djava.util.logging.config.file=/tmp/logging.properties output was:

    --- start
    09.11.2012 14:25:49 testing.Scribble main
    SCHWERWIEGEND: SEVERE 1
    09.11.2012 14:25:49 testing.Scribble main
    SCHWERWIEGEND: SEVERE 2
    09.11.2012 14:25:49 testing.Scribble main
    SCHWERWIEGEND: SEVERE 3
    09.11.2012 14:25:49 testing.Scribble main
    AM FEINSTEN: FINEST 3
    --- end
    

    Looks correct!
    (My test class is called testing.Scribble, thats the only difference)

    Using -Djava.util.logging.config.file=/tmp/logging.properties output is:

    --- start
    09.11.2012 14:31:06 testing.Scribble main
    SCHWERWIEGEND: SEVERE 1
    09.11.2012 14:31:06 testing.Scribble main
    AM FEINSTEN: FINEST 1
    09.11.2012 14:31:06 testing.Scribble main
    SCHWERWIEGEND: SEVERE 2
    09.11.2012 14:31:06 testing.Scribble main
    AM FEINSTEN: FINEST 2
    09.11.2012 14:31:06 testing.Scribble main
    SCHWERWIEGEND: SEVERE 3
    09.11.2012 14:31:06 testing.Scribble main
    AM FEINSTEN: FINEST 3
    --- end
    

    Looks also correct!

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

Sidebar

Related Questions

I have been trying to use java.util.logging.logger to log stuff on to a file
I'm trying to set java.awt.headless=true during the application startup but it appears like I'm
I am trying to set the year of a java.util.Date . he time stamp
I was just trying out the java.util.Calendar method getActualMaximum() to see if I can
I'm trying to find an implementation of java.util.List and java.util.Set at the same time
I'm trying to set Excel cell colors using Apache POI in Java. I played
I am trying to set the CLASSPATH variable so that my java programs can
I'm trying to set some custom AWS CloudWatch metrics using the Java SDK. I
I am working on a legacy Java Enterprise server project, trying to set up
I'm trying to parse a webpage using Java with URLConnection. I try to set

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.