Ptec wrote:We now need , that if ProcessError is executed, a custom String Text will be written to the "TM1ProcessError_Timestamp_Processname.log" is written, which are automatically generated in the "Logfiles" folder.
First of all it's worth remembering that once you execute ProcessError then no other code will run, so any custom log outputs need to happen before or instead of ProcessError. Also, LogOutput allows you to write to the server log, not to process error logs.
If errors are encountered during the execution of a process, a temporary 'log$' file is created. If you use ASCIIOUTPUT to write to a file with the same name with the 'log' extension then it's likely to be overwritten at the end when 'log$' is renamed to 'log'. If you try and write to the 'log$' file then that will fail too because the file is locked by the server.
One way to do what you want is to use ItemReject( YourCustomErrorString ) - this will add an entry to the error log that will contain the encountered record (on Metadata/Data) as well as your message. This is at the cost of stopping the execution of the rest of the code on the tab. On Metadata/Data it will just go straight to the next record, but when used in Prolog it will skip the rest of Prolog, so be careful with your code structure. What some people do is set a flag variable (e.g. nErrorFound=1) and raise a ProcessBreak when an issue is encountered (this causes a jump to Epilog) and then in Epilog you check if the flag variable is set and if yes, you do an ItemReject there.
But why not use ASCIIOutput to write to your own custom logs seperate to the ones TM1 generates automatically? You can use a naming convention that is similar. Just catch all the possible errors in the code and print them out to custom logs in any format you like.