Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

win32 OutputDebugString() consumer written in Java

Thread view: 
Lyall - 04 May 2006 05:16 GMT
I have windows programs that use OutputDebugString().  (see
http://www.unixwiz.net/techtips/outputdebugstring.html for an overview)

I would like to be able to write a program which consumes this output
in java. My reasoning is that I want to take the debug messages and
plonk them through log4j - where I have some fancy filtering/rolling
and delivery options setup.

This would involve the Java program calling assorted Win32 api's (the
name and order of which I have yet to determine).

I was wondering if anyone has come across anything I can leverage?
Sample programs that call windows native methods, maybe even a program
which consumes the debug output of this framework.

Any help would be gratefully appreciated.

...Lyall
Chris Uppal - 04 May 2006 11:06 GMT
> I have windows programs that use OutputDebugString().  (see
> http://www.unixwiz.net/techtips/outputdebugstring.html for an overview)
[quoted text clipped - 3 lines]
> plonk them through log4j - where I have some fancy filtering/rolling
> and delivery options setup.

I think you'd be better off just using a pre-packed utility program such as:
   http://www.sysinternals.com/Utilities/DebugView.html

However,

> This would involve the Java program calling assorted Win32 api's (the
> name and order of which I have yet to determine).

If you want to do this in Java, there are two possibilities -- one is to learn
how to use JNI (not trivial, but there's a good JNI book on Sun's website --
freely downloadable), and how to collect the debug output.  The page you quote
above has what looks like a reasonable treatment of that part of it (under
'Protocol').

Alternatively, you could write a standalone C or C++ program which collected
the data and forwarded it over TCP/IP (or maybe UDP/IP would be better), to one
or more listening processes written in Java (or any other language).  Come to
think of it, a bridge from OutputDebugStream to the syslog protocol (rfc 3164)
would be rather cool, and I'm surprised not to be able to find one already
existing.

   -- chris
Lyall - 05 May 2006 01:34 GMT
Thanks Chris.

Yes, I knew about the DebugView but the problem is I want to capture
particular OutputDebugString messages for subsequent analysis
(performance monitoring) so simply having DebugView look at the data is
insufficient.

DebugView has daily rolling of logs, which is too coarse grained for my
purposes.

I already have a data receiving and storage framework using log4j
SimpleSocketServer and a MySQL database (on a separate machine) which
records log4j messages generated by applications in a weblogic system.
I am trying to re-use this for the windows logging, hence, attempting
to use Java to retrieve the OuputDebugString data so that I can simply
use a log4j logger to pump the message through a SocketAppender.

An alternative, if it exists, would be a log4windows capability which
is connection compatible to log4j SimpleSocketServer such that the
windows components could 'log' messages in the same way as a Java
program does - this would do away with my entire OutputDebugString
issue.

If I have to, I will create a native windows program to read the
messages and pump them down a socket to a java receiver but I would
rather not if it can be helped.

...Lyall


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.