Toggle Debug Logging on the Fly


Reputable Poster
Hi All,

I discovered a very useful undocumented JDE API and would like to share this with the group.

Thanks to Mike Maguire and Shannon Moir for this one!

Have you found debug logging (Output=FILE in JDE.INI) to be a drag? It makes your system run like a dog, and produces a ton of output for stuff you aren't interested in. Plus you have to exit and restart OneWorld whenever you want to turn it on or off! Wouldn't it be cool if you could switch it on or off in the middle of a OW session, or even embed a call in your App or UBE to switch it on for a part of your run which is of interest then revert to whatever the original state was when done?

Well here it is! the OW APIused is :
JDERTN (BOOL) JDEWINAPI changeLogSettings (const char *szEntry, BOOL setting);

Pass in "Output" as *szEntry, and 0 or 1 as setting to switch it off or on respectively.

I've written a BSFN to wrap this, and addred in another option to query the current setting using jdeGetPrivateProfileString. Here's the guts of the BSFN. Just paste this into the "Variable Declarations" section of the BSFN skeleton created by OW:

char lpszValue[5];

... and this into the "Main Processing" section:

if (lpDS->cDebuggingOnOrOff == '0')
changeLogSettings("Output", 0);
else if (lpDS->cDebuggingOnOrOff == '1')
changeLogSettings("Output", 1);
else if (lpDS->cDebuggingOnOrOff == '2') {
// inquiry
jdeGetPrivateProfileString( "Debug", "Output", "None", lpszValue, sizeof lpszValue);
if (!strnicmp(lpszValue, "FILE", 4))
lpDS->cDebuggingOnOrOff = '1';
lpDS->cDebuggingOnOrOff = '0';

You'll also need a corresponding data structure, that just contains an EV01 value called cDebuggingOnOrOff, and paste the TypeDef into the include file for your BSFN.

I also wrote a trivial App to allow user toggling of debug logging at runtime. To do this, just create an App with one fix/inspect form and no Business View. Add a data dictionary item type A301 to display the debugging state, and call it "Display State", and add a push button to toggle the state. Next, add the "Dialog is Initialised event" as follows:

VA evt_DebugFlag_EV01 = "2"
Toggle JDE Debug Logging
VARIABLE <> cDebuggingOnOrOff
If VA frm_DebugFlag_EV01 is equal to "1"
FC Display State = "On"
FC Display State = "Off"
End If

You'll need to add a form level variable frm_DebugFlag_EV01.

And finally, add the following to the Button Pressed event for the Toggle button:

If VA frm_DebugFlag_EV01 is equal to "1"
// was on, switch off
VA frm_DebugFlag_EV01 = "0"
FC Display State = "Off"
// was off, switch on
VA frm_DebugFlag_EV01 = "1"
FC Display State = "On"
End If
Toggle JDE Debug Logging
VA frm_DebugFlag_EV01 -> cDebuggingOnOrOff

That's it. Enjoy!


<P ID="edit"><FONT SIZE=-1><EM>Edited by Sef on 1/29/02 05:55 PM.</EM></FONT></P>

Christian Audet

Staff member
Re: Toggle Debug Logging in the Fly


That's a appreciated trick !

I was looking for something like that two weeks ago and you just got it !

Look at this post in the archive :

1/11/02 08:12 AM

Remember the Old Days [Post#: 26407 ]"

This is exactly what I was looking for.

P.S. two more questions :

- who are Mike Maguire and Shannon Moir?
- Were you able to put this in a separate .EXE file ? (like DEBUG_ON.EXE and DEBUG_OFF.EXE)



Implementing B7333 (Xe) SP16.1, SQL
(Support B732, B7331 and B7332)


Legendary Poster
Re: Toggle Debug Logging in the Fly

Hi John,

Great post! Thanks to you to share this knowledge on JDEList Forum!

I suppose, everybody aggree with me to ask Sef to create a copy of John's post on the Tips & Traps board too.



B7332 SP11, ESU 4116422, Intel NT4, SQL 7 SP1
(working with B7321, B7331, XE too)


Reputable Poster
Re: Toggle Debug Logging in the Fly

Hi all, thanks for the positive feedback.

Mike and Shannon are a couple of OW hackers I know. Shannon is a CNC/Developer who pointed out the changeSettings API. Mike thought of putting it in a BSFN and I just tidied up his idea and stole all the glory.

I have not put this in a standalone exe, but that should work and would be trivial. You could associate a hotkey with the exe to make it really convenient.

Some other points:
Obviously JDE don't support undocumented API's, so these could just disappear in some upcoming OW release (unlikely though).

It is well worth trolling through jdekprto.h and other include fines in b7/system/include when you have time to kill. You'd be amazed at some of the gems hidden in there!


VIP Member
Re: Toggle Debug Logging in the Fly

Great Tip John

As you can see I have moved it straight away to the tips and traps section

Sef van den Nieuwelaar
B732 on NT, XE on NT, B732/A73 on AS400, B733 on NT

* Coming to a European City near you soon *