× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I am a big fan of re-routing System.out calls to a file because I don't
always have access to the console (i.e. when the Java is running on the
iSeries). Here is how you can redirect System.out and System.err:

PrintStream ps = new PrintStream(new CaptureStream(new
ByteArrayOutputStream()));
System.setErr(ps);
System.setOut(ps);

inner class that you put somewhere in your overall class:
class CaptureStream extends FilterOutputStream {
public CaptureStream(OutputStream aStream) {
super(aStream);
}

public void write(byte b[]) throws IOException {
try {
// put your code here to write to a file
} catch (Exception e) {
//TODO put other code here
}
}

public void write(byte b[], int off, int len) throws IOException
{
String e = new String(b, off, len);
// put your code here to write to a file
}


HTH,
Aaron Bartell
http://mowyourlawn.com

On Thu, Aug 7, 2008 at 6:36 AM, Bailey Paul <paul.bailey@xxxxxxxxx> wrote:


Hi Guys,

I am really sorry to bother you all with this, but I am trying to extend
the EditISeriesMemberCommand class so that I can intercept the
filename/connection details. I'm not a great expert in Java (more a
novice) and I hope I am on the right track. However, when I am writing
this extension, I want debug details output to System.err or a log file,
but I can't seem to find the output anywhere.

Here is the code I am trying to use: (I stripped the JavaDoc comments
from this email, because I thought it would be fairly obvious what it is
doing... but if not, then let me know)
public class VEditISeriesMemberCommand extends EditISeriesMemberCommand
{

private static Logger logger =
Logger.getLogger("net.Volvo.lpexExtensions.VEditISeriesMemberCommand");

public VEditISeriesMemberCommand() {
super();
}

public boolean doCommand(LpexView lpexView,
String parameters) {
try {
FileHandler fh = new
FileHandler("c:\\mylog.txt", true);
// Send logger output to our FileHandler.
logger.addHandler(fh);
// Request that every detail gets logged.
logger.setLevel(Level.ALL);
// Log a simple INFO message.

logger.info("=>net.Volvo.lpexExtensions.VEditISeriesMemberCommand.doComm
and");
logger.info(lpexView.query("sourceName") + "\n"
+ "-> " + lpexView.toString() +
"\n"
+ "-> " + parameters);
} catch (IOException e) {
System.err.println("Error creating logfile");
}
return super.doCommand(lpexView, parameters);
}

public static boolean openMember(LpexView lpexView,
String parameters,
boolean browse) {
try {
FileHandler fh = new
FileHandler("c:\\mylog.txt", true);
// Send logger output to our FileHandler.
logger.addHandler(fh);
// Request that every detail gets logged.
logger.setLevel(Level.ALL);
// Log a simple INFO message.

logger.info("=>net.Volvo.lpexExtensions.VEditISeriesMemberCommand.openMe
mber");
logger.info(lpexView.query("sourceName") + "\n"
+ "-> " + lpexView.toString() +
"\n"
+ "-> " + parameters + "\n"
+ "-> " + browse);
} catch (IOException e) {
System.err.println("Error creating logfile");
}
return EditISeriesMemberCommand.openMember(lpexView,
parameters, browse);
}
}

I've tried to use plain "mylog.txt" and "C:\\mylog.txt" in the
FileHandler constructor but can not find the output file in my workspace
or on my C: drive, and if I try to println all that info to System.err
then it just vanishes into the aether and I can't find that output
either (I was expecting it to go to the WDSC console view.)

How do *you* output debug information when you are writing
plugins/extensions for WDSC?

(I am using v7.0.0.6 with the included JRE and "Plug-In Dependencies")


Many thanks in advance,
Paul.

--
This is the WDSC Plugin Developers (Wdsc-Plugin-Dev) mailing list
To post a message email: Wdsc-Plugin-Dev@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/wdsc-plugin-dev
or email: Wdsc-Plugin-Dev-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/wdsc-plugin-dev.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.