LogService
using Skipcheck.Tm1.Client.Services;Used in the walkthrough Run a process and read its result.
The server's logs: the message log, the transaction log (cell changes), the audit log (changes to objects and security), and the error logs processes write.
What TM1 (11.8) does here that you might not expect:
- An entry's
IDnumbers it within the response, not in the log: the same entry gets another ID in the next request, and TM1 refuses to fetch an entry by its ID (501, "Indexing of message log entries is not supported"). So there's no get by ID here. - A message log entry without a time, such as the log's first line, has the
TimeStamp0000-00-00T00:00Z; it's read asnull. - The transaction and audit logs only fill when they're switched on (a cube's
logging, and
AuditLogin the configuration).
Read the newest message log entries:
// The 50 newest entries, newest first
return tm1.Logs.MessageLogAsync(true, ODataQuery.None().Top(50));
Follow the message log for errors:
// Errors as they're written, until the enumeration is cancelled; each poll is every 5 s
return tm1
.Logs.TailMessageLogAsync(TimeSpan.FromSeconds(5))
.Where(entry => entry.Level == LogLevel.Error)
.Select(entry => $"{entry.Logger}: {entry.Message}");
Read a process's error logs:
// What each error log of one process says
await foreach (var file in tm1.Logs.ErrorLogFilesAsync())
{
if (file.Filename?.EndsWith("_Load Sales.log", StringComparison.Ordinal) == true)
{
yield return await tm1.Logs.ErrorLogContentAsync(file.Filename);
}
}
Count the cell changes in the transaction log:
// How many cell changes the transaction log holds, leaving out its status lines
return await tm1.Logs.TransactionLogAsync(false, true).LongCountAsync();
Members
LogService constructor | A service that sends its requests through session. |
MessageLogEntriesAsync | GET MessageLogEntries, streamed, oldest first unless ordered otherwise. |
MessageLogAsync | The message log, streamed, newest first if reverse. |
TransactionLogEntriesAsync | GET TransactionLogEntries, streamed. |
TransactionLogAsync | The transaction log, streamed. |
AuditLogEntriesAsync | GET AuditLogEntries, streamed; empty unless the audit log is on. |
TailMessageLogAsync | Follows the message log. |
TailTransactionLogAsync | Follows the transaction log, as TailMessageLogAsync does the message log. |
TailAuditLogAsync | Follows the audit log, as TailMessageLogAsync does the message log. |
ErrorLogFilesAsync | GET ErrorLogFiles, streamed. |
ErrorLogFileAsync | GET ErrorLogFiles('name'). |
ErrorLogContentAsync | What the file says, as text, read whole. |
LogService
constructorLogService(Tm1Session session)A service that sends its requests through session.
MessageLogEntriesAsync
IAsyncEnumerable<MessageLogEntry> MessageLogEntriesAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)GET MessageLogEntries, streamed, oldest first unless ordered otherwise.
TM1 REST EntitySet MessageLogEntries
MessageLogAsync
IAsyncEnumerable<MessageLogEntry> MessageLogAsync(bool reverse, ODataQuery? query = null, CancellationToken cancellationToken = default)MessageLog(Reverse=…): the message log, streamed, newest first if reverse.
TM1 REST FunctionImport MessageLog
TransactionLogEntriesAsync
IAsyncEnumerable<TransactionLogEntry> TransactionLogEntriesAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)GET TransactionLogEntries, streamed. Besides cell changes, the log holds status
lines (such as CubeSerialized: …) with only StatusMessage set.
TM1 REST EntitySet TransactionLogEntries
TransactionLogAsync
IAsyncEnumerable<TransactionLogEntry> TransactionLogAsync( bool reverse, bool ignoreStatusMessages, ODataQuery? query = null, CancellationToken cancellationToken = default )TransactionLog(Reverse=…,IgnoreStatusMessages=…): the transaction log, streamed.
TM1 REST FunctionImport TransactionLog
AuditLogEntriesAsync
IAsyncEnumerable<AuditLogEntry> AuditLogEntriesAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)GET AuditLogEntries, streamed; empty unless the audit log is on. Expand
AuditDetails for each entry's details.
TM1 REST EntitySet AuditLogEntries Navigation AuditLogEntry/AuditDetails
TailMessageLogAsync
IAsyncEnumerable<MessageLogEntry> TailMessageLogAsync(TimeSpan every, CancellationToken cancellationToken = default)Follows the message log: the entries written from the moment of enumerating, polling
every every until the caller stops or cancels. Built on
TailMessageLog() (schema 11.3.0). TailMessageLog() returns a delta link, but TM1
(11.8) answers it with every entry since the link was made, each time, and with no next link.
So this keeps the one link and skips the entries it has already yielded, and each poll fetches
more the longer it runs. For a long watch, start afresh now and then.
TM1 REST FunctionImport TailMessageLog
TailTransactionLogAsync
IAsyncEnumerable<TransactionLogEntry> TailTransactionLogAsync(TimeSpan every, CancellationToken cancellationToken = default)Follows the transaction log, as TailMessageLogAsync does the message log.
Built on TailTransactionLog() (schema 11.3.0).
TM1 REST FunctionImport TailTransactionLog
TailAuditLogAsync
IAsyncEnumerable<AuditLogEntry> TailAuditLogAsync(TimeSpan every, CancellationToken cancellationToken = default)Follows the audit log, as TailMessageLogAsync does the message log. Built
on TailAuditLog() (schema 11.6.0).
TM1 REST FunctionImport TailAuditLog
ErrorLogFilesAsync
IAsyncEnumerable<ErrorLogFile> ErrorLogFilesAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)GET ErrorLogFiles, streamed: the error logs processes have written, such as
tm1processerror_<time>_<process>.log.
TM1 REST EntitySet ErrorLogFiles
ErrorLogFileAsync
Task<ErrorLogFile> ErrorLogFileAsync(string filename, ODataQuery? query = null, CancellationToken cancellationToken = default)GET ErrorLogFiles('name').
TM1 REST EntitySet ErrorLogFiles
ErrorLogContentAsync
Task<string> ErrorLogContentAsync(string filename, CancellationToken cancellationToken = default)GET ErrorLogFiles('name')/Content: what the file says, as text, read whole. TM1
(11.8) starts it with a byte order mark, which is dropped.
TM1 REST EntitySet ErrorLogFiles