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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:03:36+00:00 2026-05-26T21:03:36+00:00

i have a little weird task. The following (stripped) code is given (but i

  • 0

i have a little weird task. The following (stripped) code is given (but i cannot change / enhance it):

public class CustomTestClass {

    /**
     * Logger.
     */
    private Logger logger = Logger.getLogger("com.custom.testing");

    @Test
    public void simpleTestCaseOne(){
        logger.warning("simpleTestCaseOne: Not yet implemented!");
        assertTrue(true);
    }

    @Test
    public void simpleTestCaseTwo(){
        logger.warning("simpleTestCaseTwo: Not yet implemented!");
        assertTrue(true);
    }
}

Right now i use the following Ant-Code to run the tests:

<target name="Junit_Test" 
        depends="compile.test" description="Custom TestCase Runner">
        <junit printsummary="yes" haltonfailure="no" fork="yes">
            <jvmarg value="-Djava.util.logging.config.file=res/logging.properties" />
            <classpath>
                <path refid="tests.class.path" />
                <fileset dir="${src.tests}">
                    <include name="**/*Test*.java"/>
                </fileset>
            </classpath>
            <test name="com.custom.testing.CustomTestClass" 
                haltonfailure="no" 
                todir="${reports.tests}/xml"
                methods="simpleTestCaseOne" >
                   <formatter type="xml" />
            </test>
        </junit>
    </target>

The logging.properties file just defines a ConsoleHandler, FileHandler and an output file for the logger of the TestClass.

When i run the ant script, it actually works fine, but i need to rerun the tests a few times and change the output file for the FileHandler each time.

Is it possible to add/change a FileHandler for the specified Logger without changing code ?

  • 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-26T21:03:37+00:00Added an answer on May 26, 2026 at 9:03 pm

    I don’t particularly like this, but…

    You could make a logging configuration file with a replaceable token in the value of the property java.util.logging.FileHandler.pattern, e.g.

    java.util.logging.FileHandler.pattern=%h/logs/@LOGFILE@.log
    

    Then you could use the Ant copy task with a filterset to substitute the token, e.g.

    <copy file="res/logging_tmp.properties" toFile="res/logging.properties" force="true">
      <filterset>
        <filter token="LOGFILE" value="your_value"/>
      </filterset>
    </copy>
    

    You would do the copy before each execution of your unit tests, specifying a different value each time.

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

Sidebar

Related Questions

I have run into a rather weird little problem. In the following code I
This is a little weird. I have the following scenario: A page containing a
I have a little / weird behaviour here and Im looking over internet and
I have little knowledge of Flash but for a little Flash game I have
I have little bit longer question for you - but hope answer will be
I have the unfortunate task of cleaning up a bunch of old ColdFusion code.
Well!! My question is little weird .. I have created an chat channel which
The question is a little bit weird, but that's what I need ;) Usually,
I have a little weird behavior with my ASP.NET MVC 2 application. I'm using
I am having a weird error when using Omniauth. This appears to have little

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.