Class LogService
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().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 Summary
ConstructorsConstructorDescriptionLogService(Tm1Session session) A service sending its requests throughsession. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Flux<AuditLogEntry> auditLogEntries(ODataQuery query) GET AuditLogEntries, streamed; empty unless the audit log is on.reactor.core.publisher.Mono<String> errorLogContent(String filename) GET ErrorLogFiles('name')/Content: what the file says, as text, read whole.reactor.core.publisher.Mono<ErrorLogFile> errorLogFile(String filename, ODataQuery query) GET ErrorLogFiles('name').reactor.core.publisher.Flux<ErrorLogFile> errorLogFiles(ODataQuery query) GET ErrorLogFiles, streamed: the error logs processes have written, such astm1processerror_<time>_<process>.log.reactor.core.publisher.Flux<MessageLogEntry> messageLog(boolean reverse, ODataQuery query) MessageLog(Reverse=…): the message log, streamed, newest first ifreverse.reactor.core.publisher.Flux<MessageLogEntry> messageLogEntries(ODataQuery query) GET MessageLogEntries, streamed, oldest first unless ordered otherwise.reactor.core.publisher.Flux<AuditLogEntry> tailAuditLog(Duration every) Follows the audit log, astailMessageLog(Duration)does the message log.reactor.core.publisher.Flux<MessageLogEntry> tailMessageLog(Duration every) Follows the message log: the entries written from the moment of subscribing, polling everyeveryuntil cancelled.reactor.core.publisher.Flux<TransactionLogEntry> tailTransactionLog(Duration every) Follows the transaction log, astailMessageLog(Duration)does the message log.reactor.core.publisher.Flux<TransactionLogEntry> transactionLog(boolean reverse, boolean ignoreStatusMessages, ODataQuery query) TransactionLog(Reverse=…,IgnoreStatusMessages=…): the transaction log, streamed.reactor.core.publisher.Flux<TransactionLogEntry> transactionLogEntries(ODataQuery query) GET TransactionLogEntries, streamed.
-
Constructor Details
-
LogService
A service sending its requests throughsession.- 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 onLevelorTimeStamp), 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 ifreverse.- Parameters:
reverse- whether to start with the newest entryquery- 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 asCubeSerialized: …) with onlyStatusMessageset.TM1 (11.8) logs a password being set as a change of the
PASSWORDcell 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 onCube), 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 entryignoreStatusMessages- whether to leave out status lines, keeping cell changesquery- 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 everyeveryuntil cancelled. Built onTailMessageLog()(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, astailMessageLog(Duration)does the message log. Built onTailTransactionLog()(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, astailMessageLog(Duration)does the message log. Built onTailAuditLog()(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 astm1processerror_<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 namequery- what to select- Returns:
- the file, or a
Tm1NotFoundExceptionif 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
-