Ben
Ben

Reputation: 62356

Java console log how to hide method execution

I'm running a .jar file and when I do run it, I'm seeing my methods being executed...

INFO: ------- Order #295389
Mar 11, 2013 2:10:31 PM com.production.tasks.ImportNewOrders checkForOrders
INFO:     - Order has already been imported
Mar 11, 2013 2:10:31 PM com.production.tasks.ImportNewOrders checkForOrders
INFO: ...finished fetching orders, will check again in 60 seconds

I would much rather just see...

INFO: ------- Order #295389
INFO:     - Order has already been imported
INFO: ...finished fetching orders, will check again in 60 seconds

How can I block method execution from the output?

Upvotes: 1

Views: 1454

Answers (4)

Ben
Ben

Reputation: 62356

It wasn't log4j doing this, but it was actually java.util.logging logging each method call.

This will hide the method calls:

System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s%n");

Upvotes: 0

martinez314
martinez314

Reputation: 12332

If you are using Log4J, find your log4j.properties file. Note the ConversionPattern properties used. In particular, I think you need to remove C (fully-qualified class name) and M (method name). See here for a complete list of options.

Upvotes: 1

Aman J
Aman J

Reputation: 1855

You have to change Log level to log only higher level logs. It's INFO right now(guessed from your output in question) you can set it WARN that will only log messages that are warning or of higher level. You can find those setting in configuration file. For more information about different levels go through this link for log4j.

Upvotes: 1

Jeff Storey
Jeff Storey

Reputation: 57192

That is not standard java output. It looks like you have a logging framework logging that out (likely log4j, slf4j, logback, java logger, or commons logging). You would have to configure your logging to not print out the method information.

Upvotes: 0

Related Questions