Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319484 - Setting log handler (java.util.logging.FileHandler.formatter) ignored
Summary: Setting log handler (java.util.logging.FileHandler.formatter) ignored
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-11 04:44 EDT by kcassell2001 CLA
Modified: 2010-07-14 16:43 EDT (History)
4 users (show)

See Also:


Attachments
Specifies the log properties (2.50 KB, application/octet-stream)
2010-07-11 04:46 EDT, kcassell2001 CLA
no flags Details
A modified SampleAction for HelloWorld (2.06 KB, text/x-java)
2010-07-11 04:49 EDT, kcassell2001 CLA
no flags Details
Log file when run as a Java app (125 bytes, application/octet-stream)
2010-07-11 04:51 EDT, kcassell2001 CLA
no flags Details
Log file when run as a plug-in (740 bytes, application/octet-stream)
2010-07-11 04:53 EDT, kcassell2001 CLA
no flags Details
The custom log formatter (1.33 KB, text/x-java)
2010-07-11 04:54 EDT, kcassell2001 CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description kcassell2001 CLA 2010-07-11 04:44:36 EDT
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.
Comment 1 kcassell2001 CLA 2010-07-11 04:46:44 EDT
Created attachment 173965 [details]
Specifies the log properties
Comment 2 kcassell2001 CLA 2010-07-11 04:49:28 EDT
Created attachment 173966 [details]
A modified SampleAction for HelloWorld
Comment 3 kcassell2001 CLA 2010-07-11 04:51:37 EDT
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.
Comment 4 kcassell2001 CLA 2010-07-11 04:53:15 EDT
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.
Comment 5 kcassell2001 CLA 2010-07-11 04:54:57 EDT
Created attachment 173969 [details]
The custom log formatter
Comment 6 Olivier Thomann CLA 2010-07-12 08:49:22 EDT
Moving to JDT/Debug.
Comment 7 Michael Rennie CLA 2010-07-12 09:50:27 EDT
Adding Curtis for a comment from PDE. Is there anything special PDE does around logging or the like?
Comment 8 Curtis Windatt CLA 2010-07-12 14:29:50 EDT
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.
Comment 9 kcassell2001 CLA 2010-07-12 16:38:50 EDT
(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?
Comment 10 Darin Wright CLA 2010-07-14 16:37:30 EDT
(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.
Comment 11 Darin Wright CLA 2010-07-14 16:42:56 EDT
Perhaps this helps:

http://dev.eclipse.org/newslists/news.eclipse.platform/msg68257.html
Comment 12 Darin Wright CLA 2010-07-14 16:43:14 EDT
Marking as won't fix.