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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:21:24+00:00 2026-05-16T01:21:24+00:00

We are bundling Log4j 1.2.15 with our plain Swing application and load our own

  • 0

We are bundling Log4j 1.2.15 with our plain Swing application and load our own properties file from the file system at startup:

import org.apache.log4j.*;

...
System.setProperty("log4j.defaultInitOverride", "true");
...
File log4jPropertiesFile = ...
PropertyConfigurator.configure(log4jPropertiesFile.getAbsolutePath());
...

In logs we are getting from customers the output does not look like we have defined in the properties file and we are sure that not more than a very small minority edited the file themself.

Could it be that Log4j somehow overrides our settings if there is another configuration file somewhere present on the user’s machine available? How we can prevent using that?

  • 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-16T01:21:26+00:00Added an answer on May 16, 2026 at 1:21 am

    There’s a whole paragraph in the docs detailing how Log4j initializes itself:

    The exact default initialization algorithm is defined as follows:

    1. Setting the log4j.defaultInitOverride system property to any other value then “false” will cause log4j to skip the default initialization procedure (this procedure).
    2. Set the resource string variable to the value of the log4j.configuration system property. The preferred way to specify the default initialization file is through the log4j.configuration system property. In case the system property log4j.configuration is not defined, then set the string variable resource to its default value “log4j.properties”.
    3. Attempt to convert the resource variable to a URL.
    4. If the resource variable cannot be converted to a URL, for example due to a MalformedURLException, then search for the resource from the classpath by calling org.apache.log4j.helpers.Loader.getResource(resource, Logger.class) which returns a URL. Note that the string “log4j.properties” constitutes a malformed URL. See Loader.getResource(java.lang.String) for the list of searched locations.
    5. If no URL could not be found, abort default initialization. Otherwise, configure log4j from the URL. The PropertyConfigurator will be used to parse the URL to configure log4j unless the URL ends with the “.xml” extension, in which case the DOMConfigurator will be used. You can optionaly specify a custom configurator. The value of the log4j.configuratorClass system property is taken as the fully qualified class name of your custom configurator. The custom configurator you specify must implement the Configurator interface.

    This is, admittedly, confusing as hell to understand. Basically, the simplest thing you can do is put log4j.properties on the classpath of your app, and it will be found. Everything else is… finesse. Personally, I sometimes explicitly call the BasicConfigurator class in my main, sometimes configuring (hard coded) some of the stuff that might otherwise appear in a file… whatever my circumstances call for. You can initialize log4j completely programmatically, and that would kind of make the question of the configuration file moot. Though it would also make your configuration completely less flexible.

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

Sidebar

Related Questions

I'm bundling an application for distribution and SQL Server is a prequisite so we're
I have a wxPython application I'm bundling into an exe using py2exe. I've defined
I have a strange requirement to ship an application without bundling .Net framework (to
I'm trying out MVC 4 Beta's bundling and minification thru System.Web.Optimization . I was
Possible Duplicate: Bundling images with Blackberry hi i am doing blackberry application development for
I'm bundling ttf files in a jar file and intend to use them as
I am implementing the bundling and minification support in MVC4 and setting it up
I am implementing the bundling and minification support in MVC4 and it appears as
I would like to use the bundling and mimification features of MVC4 but I
So MVC 4 introduces script and style bundling. Which allows for this: public static

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.