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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:41:45+00:00 2026-05-31T23:41:45+00:00

I am fairly new to Java so am looking for a good way of

  • 0

I am fairly new to Java so am looking for a good way of controlling the amount of diagnostic output a package would produce during execution.

So suppose I have a package that gets integrated into different programs. For simplicity let’s assume that I want to either produce no diagnostic output during execution or produce some output which would be sent to System.out. The question is what is the most elegant and reliable way of doing that.

Can I create a global boolean variable inside the package whose value would be set at one or more points in the application that invokes this package, and then I would check its value at every point in the package where I want to produce diagnostic output. This way I would not have to do pass a controlling parameter into every method of every class in the package.

Is there a better way?

Thanks!

  • 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-31T23:41:46+00:00Added an answer on May 31, 2026 at 11:41 pm

    You should take a look at logging. Log4j is one example. Avoid using System.out.printlns in your code completely.

    With log4j, you can configure something like the below which would turn off all logging output that the package com.foo.mypackage produces.

    log4j.logger.com.foo.mypackage=OFF
    

    Once you’re past that stage, I suggest you take a look at SLF4J and Logback.

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

Sidebar

Related Questions

I'm fairly new to java and looking for an interface that simply guarantees that
Im fairly new to Java and im just looking for a little help Im
I am fairly new to Java EE and JMS and am looking at doing
I am still fairly new to Java programming and I was looking over a
I'm fairly new to Java, and I need some help figuring out a good
I'm fairly new to Java (been writing other stuff for many years) and unless
I'm fairly new to Java and am writing an app that needs an XML
I am fairly new to Java, and I am trying to construct a very
I'm fairly new to programming and new to java, but I'd like to jump
I am new to IntelliJ (and Stackoverflow) and fairly new to Java,In my application

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.