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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:07:36+00:00 2026-06-15T12:07:36+00:00

I would like to override log4j configuration at runtime with DOMConfigurator.configureAndWatch() function. It’s work

  • 0

I would like to override log4j configuration at runtime with DOMConfigurator.configureAndWatch() function. It’s work when the string name of file parameter is hard-coded. For example : DOMConfigurator.configureAndWatch("C:/some/path/log4j.xml");

But my log4j.xml is in EAR file (in a JAR in the lib directory) and how can I access it at runtime ?

I tested DOMConfigurator.configureAndWatch("log4j.xml"); but it seems that Glassfish is trying to search file from ${GLASSFISH_HOME}/glassfish/domains/domain1/config where is located my old log4j.xml file to override…so actually my code load, reset and reload configuration from the same file…

I’m just looking for a way to load my log4j.xml inside my EAR

Thanks for ideas

  • 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-15T12:07:37+00:00Added an answer on June 15, 2026 at 12:07 pm

    Invoke getClass().getResourceAsStream("/log4j.xml") on a class in your JAR/EAR to read the log4j.xml file located at the root of the JAR/EAR. Then, pass the resulting InputStream to DOMConfigurator.doConfigure(InputStream, LoggerRepository)

    Alternatively, you can invoke DOMConfigurator.configure(getClass().getResource("/log4j.xml")), where getClass() returns a Class object in your JAR/EAR.

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

Sidebar

Related Questions

I would like to override Url.Content to append a query string parameter to the
I would like to temporarily override the kill-new function. I have a way I
I would like to override a generic function in a subclass, as follows: Superclass:
I'm using the plotmatrix function in ggplot2 (ggplot2_0.8.8) and would like to override the
Is it possible to add or override log4j configuration previously loaded by log4j.xml file
I would like to override the comment_save function. Is there a way to override
Specifically I would like to override the getElementsByClassName function that is available in every
I would like to override Tekerik's javascript function. To do that I want to
I would like to override an object property with a function, so that whenever
I would like to override the _() PHP function so that it supports one

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.