Skip to content

Log View

Last updated 15 Nov 2026

NbLogView is read-only output: a log or a terminal, in monospace, following the newest line unless the reader scrolled up, with a copy-all action. It renders only the newest lines, so a log that runs for hours stays as quick as one that just started.

It fills the height it is given and scrolls inside it. Give it a height through its container or a max-height.

Props ​

PropTypeDefaultDescription
linesReadonlyArray<ILogLine | string>requiredThe lines, oldest first
maxLinesnumber1000The most lines rendered: the newest. The rest are counted in a note. 0 renders every one
followbooleantrueFollows the newest line while the reader is at the end
wrapbooleantrueWraps long lines. Off, the log scrolls sideways
copyablebooleantrueShows the copy-all button
labelstringcatalogueThe log's accessible name (logViewLabel, "Log")
announcebooleanfalseAnnounces new lines to a screen reader
emptyTextstringcatalogueWhat the empty log says (logViewEmpty, "No output yet")
localestringruntimeBCP 47 tag for formatting line times

ILogLine ​

FieldTypeDescription
idstring | numberA stable key. Without it the line's position is used
textstringThe line
timestring | number | DateWhen it was written, shown as a time of day with seconds
timeLabelstringA ready-made time string, used in place of the formatted time
levelTLogLevel'error' | 'warning' | 'info' | 'debug'
markerstringA short word before the text. Defaults to the level's word for error and warning

Slots ​

SlotDescription
emptyShown while there are no lines

Exposed ​

NameTypeDescription
scrollToNewest() => voidScrolls the log to the newest line

Strings ​

From the catalogue, through provideNbStrings(): logViewLabel, logViewEmpty, logViewCopy ("Copy log"), logViewHidden(count) ("1,500 earlier lines not shown"), logViewError and logViewWarning (the default markers), and jumpToNewest, shared with NbChatThread.

Copy ​

Copy-all copies every line in lines, including those not rendered, one per line, each as it is shown: time, marker and text separated by spaces.

Appending ​

Push to the array. Lines are keyed by id, or by their position when they have none, which stays stable as long as lines are only appended. A log that trims its own oldest lines should give each one an id.

ts
const output = ref<ILogLine[]>([])
source.onmessage = (event) => output.value.push(JSON.parse(event.data))