Class LogService

java.lang.Object
io.skipcheck.tm1.client.service.server.LogService

public final class LogService extends Object
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 ID numbers 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 TimeStamp 0000-00-00T00:00Z; it's read as null.
  • The transaction and audit logs only fill when they're switched on (a cube's logging, and AuditLog in the configuration).

Read the newest message log entries:

// The 50 newest entries, newest first
return tm1.logs().messageLog(true, ODataQuery.none().top(50));

Follow the message log for errors:

// Errors as they're written, until the subscriber cancels; each poll is every 5 s
return tm1.logs()
	.tailMessageLog(Duration.ofSeconds(5))
	.filter(entry -> entry.level() == LogLevel.ERROR)
	.map(entry -> entry.logger() + ": " + entry.message());

Read a process's error logs:

// What each error log of one process says
return tm1.logs()
	.errorLogFiles(ODataQuery.none())
	.filter(file -> file.filename() != null && file.filename().endsWith("_Load Sales.log"))
	.concatMap(file -> tm1.logs().errorLogContent(file.filename()));

Count the cell changes in the transaction log:

// How many cell changes the transaction log holds, leaving out its status lines
return tm1.logs().transactionLog(false, true, ODataQuery.none()).count();
  • Constructor Details

    • LogService

      public LogService(Tm1Session session)
      A service sending its requests through session.
      Parameters:
      session - the session
  • Method Details

    • messageLogEntries

      @Tm1Endpoint("EntitySet MessageLogEntries") public reactor.core.publisher.Flux<MessageLogEntry> messageLogEntries(ODataQuery query)
      GET MessageLogEntries, streamed, oldest first unless ordered otherwise.
      Parameters:
      query - what to select, filter (such as on Level or TimeStamp), order and how many
      Returns:
      the entries
    • messageLog

      @Tm1Endpoint("FunctionImport MessageLog") public reactor.core.publisher.Flux<MessageLogEntry> messageLog(boolean reverse, ODataQuery query)
      MessageLog(Reverse=…): the message log, streamed, newest first if reverse.
      Parameters:
      reverse - whether to start with the newest entry
      query - what to select, filter and how many
      Returns:
      the entries
    • transactionLogEntries

      @Tm1Endpoint("EntitySet TransactionLogEntries") public reactor.core.publisher.Flux<TransactionLogEntry> transactionLogEntries(ODataQuery query)
      GET TransactionLogEntries, streamed. Besides cell changes, the log holds status lines (such as CubeSerialized: …) with only StatusMessage set.

      TM1 (11.8) logs a password being set as a change of the PASSWORD cell of ClientProperties}, and writes the new value, the password's hash, as raw bytes that aren't UTF-8. They read as U+FFFD, the replacement character, here and in the other transaction log methods.

      Parameters:
      query - what to select, filter (such as on Cube), order and how many
      Returns:
      the entries
    • transactionLog

      @Tm1Endpoint("FunctionImport TransactionLog") public reactor.core.publisher.Flux<TransactionLogEntry> transactionLog(boolean reverse, boolean ignoreStatusMessages, ODataQuery query)
      TransactionLog(Reverse=…,IgnoreStatusMessages=…): the transaction log, streamed.
      Parameters:
      reverse - whether to start with the newest entry
      ignoreStatusMessages - whether to leave out status lines, keeping cell changes
      query - what to select, filter and how many
      Returns:
      the entries
    • auditLogEntries

      @Tm1Endpoint("EntitySet AuditLogEntries") @Tm1Endpoint("Navigation AuditLogEntry/AuditDetails") public reactor.core.publisher.Flux<AuditLogEntry> auditLogEntries(ODataQuery query)
      GET AuditLogEntries, streamed; empty unless the audit log is on.
      Parameters:
      query - what to select, filter, order, and expand (AuditDetails, the entry's details)
      Returns:
      the entries
    • tailMessageLog

      @Tm1Endpoint("FunctionImport TailMessageLog") public reactor.core.publisher.Flux<MessageLogEntry> tailMessageLog(Duration every)
      Follows the message log: the entries written from the moment of subscribing, polling every every until cancelled. 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 emitted, and each poll fetches more the longer it runs. For a long watch, subscribe afresh now and then.

      Parameters:
      every - how long to wait between polls
      Returns:
      the new entries, as they come
    • tailTransactionLog

      @Tm1Endpoint("FunctionImport TailTransactionLog") public reactor.core.publisher.Flux<TransactionLogEntry> tailTransactionLog(Duration every)
      Follows the transaction log, as tailMessageLog(Duration) does the message log. Built on TailTransactionLog() (schema 11.3.0).
      Parameters:
      every - how long to wait between polls
      Returns:
      the new entries, as they come
    • tailAuditLog

      @Tm1Endpoint("FunctionImport TailAuditLog") public reactor.core.publisher.Flux<AuditLogEntry> tailAuditLog(Duration every)
      Follows the audit log, as tailMessageLog(Duration) does the message log. Built on TailAuditLog() (schema 11.6.0).
      Parameters:
      every - how long to wait between polls
      Returns:
      the new entries, as they come
    • errorLogFiles

      @Tm1Endpoint("EntitySet ErrorLogFiles") public reactor.core.publisher.Flux<ErrorLogFile> errorLogFiles(ODataQuery query)
      GET ErrorLogFiles, streamed: the error logs processes have written, such as tm1processerror_<time>_<process>.log.
      Parameters:
      query - what to select, filter and order
      Returns:
      the files
    • errorLogFile

      @Tm1Endpoint("EntitySet ErrorLogFiles") public reactor.core.publisher.Mono<ErrorLogFile> errorLogFile(String filename, ODataQuery query)
      GET ErrorLogFiles('name').
      Parameters:
      filename - the file's name
      query - what to select
      Returns:
      the file, or a Tm1NotFoundException if there's none
    • errorLogContent

      @Tm1Endpoint("EntitySet ErrorLogFiles") public reactor.core.publisher.Mono<String> errorLogContent(String filename)
      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.
      Parameters:
      filename - the file's name
      Returns:
      the text