Community
Participate
Working Groups
Build Identifier: Version: 3.5.2 Build id: M20100211-1343 I have legacy code that I want to be able to use both within the plug-in and in the old standalone code. This code uses java.util.logging. I want to use a custom log handler. I debug my plug-in by starting up a new workbench using a JVM option "-Djava.util.logging.config.file=c:/logging.properties". The logging.properties file appears to be read, because the file specified by java.util.logging.FileHandler.pattern is being written. Unfortunately, the custom formatter that I specified via java.util.logging.FileHandler.formatter does not seem to get called; the output in the file is in what looks to be a default XML format. The logging works okay in the legacy code, i.e., my custom formatter gets used. Reproducible: Always Steps to Reproduce: 1. Create a HelloWorld plug-in 2. Add some logging using java.util.logging.Logger 3. Create an Eclipse Application debug configuration. 4. Add a VM argument - "-Djava.util.logging.config.file=c:/logging.properties" 5. Within logging.properties, add a line specifying a custom formatter, e.g. "java.util.logging.FileHandler.formatter = nz.ac.vuw.ecs.kcassell.logging.ConciseLogFormatter" 6. Run the debug configuration. Log messages will be in an XML format.
Created attachment 173965 [details] Specifies the log properties
Created attachment 173966 [details] A modified SampleAction for HelloWorld
Created attachment 173967 [details] Log file when run as a Java app If I run the SampleAction as a Java app, I get the desired log file output.
Created attachment 173968 [details] Log file when run as a plug-in If I run SampleAction from the spawned workspace, I get the undesirable XML log file.
Created attachment 173969 [details] The custom log formatter
Moving to JDT/Debug.
Adding Curtis for a comment from PDE. Is there anything special PDE does around logging or the like?
PDE owns the log view, but it hooks into the Eclipe logging framework, not with java's logging utils. Since the file is getting pinged, it seems likely the java logger is having trouble parsing the properties file into a proper formatter. This does not look like an Eclipse bug.
(In reply to comment #8) > PDE owns the log view, but it hooks into the Eclipe logging framework, not with > java's logging utils. Since the file is getting pinged, it seems likely the > java logger is having trouble parsing the properties file into a proper > formatter. This does not look like an Eclipse bug. I don't follow your analysis. First, if I run the SampleAction as a Java app, I get correct behavior as shown by the second attached log file. Second, when run as a plug-in, at least some of the properties file is being read correctly, because the log file is showing up in the correct location as specified in the properties file. So, what is it that makes you say it looks like a Java bug and not an Eclipse bug? As a wild guess on my part, is there some exotic class-loading that occurs when debugging plug-ins?
(In reply to comment #9) > As a wild guess on my part, is there some exotic class-loading that occurs when > debugging plug-ins? Yes - an OSGi class loader is used when running/debugging plug-ins. When run as a plain java application, I assume the logger is found on the runtime classpath. When run as an OSGi app, there is no runtime classpath as such... OSGi instead knows which bundles are to be run, and each bundle gets a class loader.
Perhaps this helps: http://dev.eclipse.org/newslists/news.eclipse.platform/msg68257.html
Marking as won't fix.