Hello,

how can copy and save the console message to a file using logger.
i try this :Click Here

but it's only saving warning and info messages to my file.

thank you

Recommended Answers

All 2 Replies

The System.setOut and System.setErr methods redirect all console output to a print stream of your choice.

@Neversleepin
I saw the code in the link provided by you.
I see that you created a custom logger of type "java.util.logging.Logger".
While defing the logger you have not set the default logging level .

Please set the default logging level in your code like this

logger.setLevel(Level.ALL);// there are more stringent  and less stringent levels than this.

You can set what ever suitable for you.

if you set "Level.ALL" then during logging the individual log messages you can log choose any of these at the time of logging.

logger.log(Level.INFO,"Test Messsage.");
logger.log(Level.WARNING,"Test Messsage.");
 logger.log(Level.SEVERE,"Test Messsage.");
logger.log(Level.INFO,"Test Messsage.");
logger.log(Level.WARNING,"Test Messsage.");
logger.log(Level.ALL,"Test Messsage.");

You can choose any logging Level you need at that time of individual log messages depending upon your need in the actual code.
This provides you the needed flexibility by setting the default logging level to Level.ALL.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.