Totally disabling java net ssl debug logging

Viewed 3024

I've found tons of documentation on how to enable javax.net.debug for SSL, TLS and similar, but even in the reference documentation I've not found how to totally disable it overriding programmatically a previous setting.

My exact problem is that in a Tomcat instance another application performs the following instruction:

System.setProperty("javax.net.debug","all");

and this causes the catalina.out file to rise his dimension quickly and unwanted.

I've already tried to overwrite it from my Java code with the same instruciton, with "none", "off" and "false" values but with no result, still logging a plenty of TLS stuff.

For example in my application I've added this instruction:

System.setProperty("javax.net.debug","none");

but still I'm getting full log.

4 Answers

The problem is that the tomcat application is overwriting whatever value you give from command line, and if there is no way to control what this code is doing, you can't really overwrite it from commandline arguments. While a security manager would be able to prevent setting a property, it can only do so by throwing an exception, which is probably going to cause more issues than it solves.

In this case, your only option is to set the value yourself from code, after the other code sets it.

In case of the javax.net.debug, the option needs to be set to it's final value before the static static initializer of sun.* Debug class runs, which is before the first message would appear. This can be disabled by any value that isn't used as some option (empty string, or none should disable it). If it's set later, it will have no effect with no way to turn it off after the fact (with the exception of doing some bad reflection hacks to access internals of that class anyway, that are only possible with java 8 and earlier)

If there are some VM argument that enable SSL logging try to remove them, in addition you can check eclipse.ini file to see if those arguments are declared there or not.

You can disable it by removing the following from the run configuration in your IDE:

-Djavax.net.debug=all

To anyone who may need this, I set the value to an empty string: System.setProperty("javax.net.debug",""); It worked for me.

Related