Write to log from JScript
How do I write to the metastorm logs (procedure logs) from a Jscript ?
something equivalent to log.error() from Java based BPM tools ?
Comments
-
Hi Prax,
Create a Jscript.Net script and add the following method.
public static function WriteToLogFile(FilePath:String, LogMsg:String) { var FS :FileStream = new FileStream(FilePath, FileMode.Append, FileAccess.Write); var Text :StreamWriter = new StreamWriter(FS); Text.WriteLine(System.DateTime.Now.ToString() + ": " + LogMsg); Text.Close(); FS.Close(); }
Make sure you add
import System.Text; import System.IO;
at the top of the script.
Now you can call the method e.g. like:
WriteToLogFile(logLocation + "Log.txt",String.Format("DSN: {0}",dsn));
btw: You need to give the correct permissons (trusted metastorm/engine account) to the folder/location you save to log to.
I hope that helps.
Best regards
Sascha Cutura
0 -
Thanks Sascha ... this is the way I'll have to consider if I can't write directly to eLogs or standard procedure logs.
Basically, I'm trying to avoid writing to a file based log, but instead write to eLog table directly. Sorry I didn't mention that in the original question clearly.
0 -
S Cutura wrote:
Hi Prax,
Create a Jscript.Net script and add the following method.
public static function WriteToLogFile(FilePath:String, LogMsg:String) { var FS :FileStream = new FileStream(FilePath, FileMode.Append, FileAccess.Write); var Text :StreamWriter = new StreamWriter(FS); Text.WriteLine(System.DateTime.Now.ToString() + ": " + LogMsg); Text.Close(); FS.Close(); }
Make sure you add
import System.Text; import System.IO;
at the top of the script.
Now you can call the method e.g. like:
WriteToLogFile(logLocation + "Log.txt",String.Format("DSN: {0}",dsn));
btw: You need to give the correct permissons (trusted metastorm/engine account) to the folder/location you save to log to.
I hope that helps.
Best regards
Sascha Cutura
Seriously?
Why would you not use %WriteText()? If you really did have to use a script to do this you could use ework.WriteText().
KISS!
0 -
Prax wrote:
Thanks Sascha ... this is the way I'll have to consider if I can't write directly to eLogs or standard procedure logs.
Basically, I'm trying to avoid writing to a file based log, but instead write to eLog table directly. Sorry I didn't mention that in the original question clearly.
As discussed on our forums, you should avoid writing to the Metatsorm tables directly. It would be best to use another table of your own making, I believe.
0 -
Thanks Sascha, Jerome
I'll try the file approach then or a table. I was hoping to tap into the "global log" because it would then automatically use the global settings for log purge/rollover (if any such things exist)
0 -
Prax wrote:
Thanks Sascha, Jerome
I'll try the file approach then or a table. I was hoping to tap into the "global log" because it would then automatically use the global settings for log purge/rollover (if any such things exist)
You can do this in a supported manner (no code required, either) in version 9.
0 -
From a script perspective, I think the only way you could insert to elog is by throwing an exception. You should put this into the ideas portion of this community site - it's a good idea to be able to insert a log anytime for any reason.
0
Categories
- All Categories
- 123 Developer Announcements
- 54 Articles
- 152 General Questions
- 148 Thrust Services
- 57 Developer Hackathon
- 37 Thrust Studio
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 32 eDOCS
- 190 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 10 XM Fax
- Follow Categories