Logging and Netbeans Platform
Posted: Fri Apr 05, 2013 12:30 am
How can I disable logging (or set logging level to "error") in Netbeans platform application? I use docx4j in my application as a library wrapper module. I guess the proper way would be to set correct logging levels in log4j config file and include it in classpath. If I put log4j.xml inside some module's jar file, log4j fails to load it and throws MalformedURLException. The reason why it does that is because the path to the jar file contains illegal characters (eg. 'ö' and 'ä' in 'c:/työryhmä/myApp/modules/module.jar'). Users might install my application to any directory, so avoiding "wrong" characters in path name is not possible.
I tried also to put log4j.xml to my application's (root) directory and pass path to the file at startup using parameter -J-Dlog4j.configuration=log4j.xml . This doesn't cause exception but obviously doesn't work since docx4j gives message "Log4jConfigurator .configure line 45 - Since your log4j configuration (if any) was not found, docx4j has configured log4j automatically."
I searched the forums and only workaround I found is setting log level manually in code. Eg.:
org.apache.log4j.Logger.getRootLogger().setLevel( org.apache.log4j.Level.ERROR );
Is there any better ways to fix this?
I tried also to put log4j.xml to my application's (root) directory and pass path to the file at startup using parameter -J-Dlog4j.configuration=log4j.xml . This doesn't cause exception but obviously doesn't work since docx4j gives message "Log4jConfigurator .configure line 45 - Since your log4j configuration (if any) was not found, docx4j has configured log4j automatically."
I searched the forums and only workaround I found is setting log level manually in code. Eg.:
org.apache.log4j.Logger.getRootLogger().setLevel( org.apache.log4j.Level.ERROR );
Is there any better ways to fix this?