Watch-ConsoleLog
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>]#PathWatch-ConsoleLog
[-Capacity <Int32>]
[-Count <Int64>]
[-Filter <String>]
[-Highlight <String>]
[-Interval <Double>]
-LogName <String>
[-Plain]
[-Tail <Int32>]
[-TimestampFormat <String>]
[<CommonParameters>]#EventLogDescription
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 databaseFollow a file and emphasize a component.
Example 2
Watch-ConsoleLog -Path ./service.log -Tail 50 -Filter ERROR -Count 1 | Out-File ./errors.txtCapture the current matching lines as ordinary strings.
Example 3
Watch-ConsoleLog -LogName Application -Tail 20Follow a local Windows event log.
Parameters
- -Capacity Int32
- Maximum retained history lines, default 1000.
- -Count Int64
- Source polls before returning, or zero to follow until cancelled.
- -Encoding String
- 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
- Literal case-insensitive text required in a line. Null or empty accepts every line.
- -Highlight String
- Literal case-insensitive text emphasized in live output. Plain output stays unchanged.
- -Interval Double
- Seconds between polls, from 0.05 to 86400; defaults to 0.25.
- -Path String
- One literal FileSystem path. Wildcards are not expanded.
- -Plain SwitchParameter
- Writes literal lines without a live screen or keyboard input.
- -Tail Int32
- Completed history lines or events shown initially; zero starts with later entries.
- -TimestampFormat String
- 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
- 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.