How to write the event log to the text file.

Primary tabs

Answers

Ensemble event log?

It is stored in Ens.Util.Log class, so you can easily export it to csv/html/xml/pdf/txt from SQL. Here's a sample export to CSV:

set rs = ##class(%SQL.Statement).%ExecDirect(,"SELECT * FROM Ens_Util.Log")
set file = "C:\InterSystems\Ensemble\mgr\Temp\Ens.Log"
do rs.%DisplayFormatted(100, file) // 100 for CSV format

Docs for %DisplayFormatted.

Assumedly, you also may only want to see "new" additions to the log file. My thoughts on this would be as follows;

Method 1 - Using COS code throughout

  1. Take a snapshot of the existing ens.log/cconsole.log, loading it into Cache as an Object/Global
  2. Every "n" seconds, rescan the existing log file.
  3. If new lines have appeared report them, write to text file, email, text etc. them
  4. Goto step 1

Method 2 - Using OS tools

  1. Take a snapshot of the existing log file into a copy text file
  2. Every "n" seconds, use an OS tool to compare this file with the current log file (e.g. diff in Unix etc.)
  3. If different, report the differences, write to text file, email, text etc. them
  4. Goto step 1

 

If you really only want "...to write the event log to the text file..." then you can either use COS or a simple copy command at the OS level to copy the log file to another text file