How to writing to webMethods server.log and error.log

Hi All

I want to write a message to the server.log and error.log file when a certain event occurs.

I have been searching the webMethods documentation and forums for this and cannot find any references to this.

I was wondering do people know how to do this?

Hi,

Could you please provide some additional details as to what kind of event that you are looking at? There are certain configurable event management services available in Developer (Tools > Event Manager).

Hi Thanks for you quick reply.

The event I want to log is from a flow service I am writing. I am using a previously written java service that list files from a specified directory. When the file or directory being searched for cannot be found the java service creates an error. But I do not and probably not allowed to modify this existing list files java code to perform another action. So I would like to pick up the exception generated by not being able to find the directory/file and write this error to the webMethods error or server logs.
Hope this is all not too confusing.

The java service uses the java API “File(filePath)”, when the file/directory is not found it throws an exception, which I am trying to capture in webMethods flow code and write this error in the webMethods server and error logs.

Thanks in advance for your reply.

Hi Kelvin,

To write to server log, you can write a java service and put

com.wm.util.JournalLogger.log(3,90,3,"LOG " + message );

Where message is message to log in server log.

To put in error log you can use Exist step signaling Failure and put message in Failure Message property of the step. You can use variable substitution in this failure message i.e. %lastError/error%

Cheers,
Ajit

Hi

Please excuse my ignorance but what exactly is the mentioned Exist step in webMethods?

Thanks
Kevin

Hi Kelvin,

I think what Ajit suggested was about the “Exit” step. Might be a typo.

For logging a message to server logs, the pub.flow:debugLog service can be used before the exit step in the catch block with the exact message as input. So once an exception has been raised from the above mentioned java service, it can be handled in the catch block by first logging it to the server log and then to the error log. Hope this helps.

Thanks

Exit step would create an unwanted email through IS thread.

Instead try using ‘throwException’ service (in PS Utilities package) that would log into the error log with appropriate message. Alternatively, if you have a DB as error log, I would use an adapter service to insert data.

Kevin,

Create a flow service, use try catch, and call your java service in try…

Sequence (exit on success)

Sequence (exit on failure) TRY
Call java service
Sequence (exit on done) CATCH
Call getLastError retrieves the last error
Call debugLog logs the error to server.log file

Senthil

All,

Logging to the server and error log should be reserved for technical issues only. Writing errors when a particular file is not found sounds to me like an exception relevant to your business logic. In such cases, write to either a database, or a log file outside your webMethods directory or some monitoring facility.

The debugLog service is, as the name implies, for debugging use only. Never use this for anything else and certainly not in production code.

Chris

Hi all,
Thanks for Your valuable suggessitions.

i have a user defined log file outside my webMethods directory for special purpose(say xyz.log)
Now the think is, i want to create a new tab in WMIS logs submenu tab (say pqr)
and i want to show the recent entries of xyz.log file when a user clicks on pqr tab in WMIS(creating a new dsp page - say pqr.dsp)

i am able to create the pqr tab in WMIS
But i am not able to findout a Wm service which can read a userdefined log file and which can show entries in a dsp page.

Please help me out …!!

Punith Reddy.T

Hi Punith,

If you will look at \packages\WmRoot\pub\log-server-recent.dsp file you will get what you are looking for .It has used couple of server related services from the wmRoot package which you can also use to design the custom dsp page to monitor error.

Thanks,
Amol.

Hello amolchauhan,

I gone through it after you said and now i done, what i want to do very quickly.
Thanks for your suggessition.

Punith Reddy.T

I am glad that it helped !!
Welcome.:slight_smile:

Thanks,
Amol.