Skip to content
ConsoleMonster
Cmdlet

Watch-ConsoleLog

Module
ConsoleMonster
Inputs
None
Outputs
System.String

Follows a log file or a local Windows event log with a live, scrollable log view.

Syntax

Watch-ConsoleLog
[-Capacity <Int32>]
[-Count <Int64>]
[-Encoding <String>]
[-Filter <String>]
[-Highlight <String>]
[-Interval <Double>]
[-Path] <String>
[-Plain]
[-Tail <Int32>]
[-TimestampFormat <String>]
[<CommonParameters>]
#
Parameter set: Path
Watch-ConsoleLog
[-Capacity <Int32>]
[-Count <Int64>]
[-Filter <String>]
[-Highlight <String>]
[-Interval <Double>]
-LogName <String>
[-Plain]
[-Tail <Int32>]
[-TimestampFormat <String>]
[<CommonParameters>]
#
Parameter set: EventLog

Description

File lines are decoded incrementally and followed across observed truncation and rotation. Event logs use Get-WinEvent on Windows. The view follows new entries; scrolling pauses following and End resumes it. Filter and Highlight are literal case-insensitive substrings. Piped, redirected, CI and -Plain output is ordinary literal text and never reads keyboard input. Count is source polls, as in Watch-Console: one takes a snapshot, zero follows until q, Escape or Ctrl+C. Capacity bounds retained history. The default interval is 0.25 seconds.

Examples

Example 1

Watch-ConsoleLog -Path ./service.log -Highlight database

Follow a file and emphasize a component.

Example 2

Watch-ConsoleLog -Path ./service.log -Tail 50 -Filter ERROR -Count 1 | Out-File ./errors.txt

Capture the current matching lines as ordinary strings.

Example 3

Watch-ConsoleLog -LogName Application -Tail 20

Follow a local Windows event log.

Parameters

-Capacity Int32 optional
Maximum retained history lines, default 1000.
-Count Int64 optional
Source polls before returning, or zero to follow until cancelled.
-Encoding String optionalsets: Path
File encoding without a BOM, default utf8. A UTF-8, UTF-16 or UTF-32 BOM takes precedence. Uses the same encoding names as Write-ConsoleText.
Possible values: unknown, string, unicode, bigendianunicode, utf8, utf8BOM, utf8NoBOM, utf32, ascii, default, oem
-Filter String optional
Literal case-insensitive text required in a line. Null or empty accepts every line.
-Highlight String optional
Literal case-insensitive text emphasized in live output. Plain output stays unchanged.
-Interval Double optional
Seconds between polls, from 0.05 to 86400; defaults to 0.25.
-Path String requiredposition: 0aliases: LiteralPathsets: Path
One literal FileSystem path. Wildcards are not expanded.
-Plain SwitchParameter optional
Writes literal lines without a live screen or keyboard input.
-Tail Int32 optional
Completed history lines or events shown initially; zero starts with later entries.
-TimestampFormat String optional
Explicit invariant .NET source timestamp format for the live view, at every terminal width. By default, HH:mm:ss expands to yyyy-MM-dd HH:mm:ss when retained source dates differ. Missing timestamps stay blank; plain output keeps the original text.
-LogName String requiredsets: EventLog
One literal local Windows event-log name, such as Application or System. Wildcards are not supported.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.