windows动态查看最新日志信息

2019-02-23 14:52 By "Powerless" 2897 0 1

【Get-Content】可获取的项目在通过的路径,指定的位置的内容,如在一个文件中的文本或函数的内容。对于文件,内容一次读取一行并返回一组对象,每个对象代表一行内容。

从PowerShell 3.0开始,Get-Content还可以从项目的开头或结尾获取指定数量的行。


【参数说明】

[-Path] <string[]>
[-ReadCount <long>]
[-TotalCount <long>]
[-Tail <int>][-Filter <string>]
[-Include <string[]>]
[-Exclude <string[]>]
[-Force]
[-Credential <pscredential>][-Delimiter <string>]
[-Wait]
[-Raw]
[-Encoding <Encoding>]
[-AsByteStream]
[-Stream <string>][<CommonParameters>]


【示例】

    在开始菜单的win徽标点击鼠标右键,选择打开Windows Powershell。

    我们要查看位于E:\test\log目录下的日志文件

Get-Content -path E:\test\logs\2018-12-31.log -wait -encoding UTF8 -tail 5

通过上面的命令,我们就可以查看到这个日志文件最新的5条记录和之后的新增记录


【说明】

path        文件路径
wait    等待文件内容
encoding  文件编码格式
tail    显示记录数量


【tps】

Get-Content的使用方法有很多,这里只是简单的介绍了一个比较常用的。

评 论

View in WeChat

Others Discussion

  • PHP扩展ImageMagick安装
    Posted on 2022-11-11 11:16
  • Redis各种数据类型的使用场景举例分析【三】
    Posted on 2018-11-22 17:00
  • TCP协议的特性
    Posted on 2019-04-26 16:46
  • 前端知识体系精简-Css
    Posted on 2018-03-28 18:34
  • 一些常见的基础概念
    Posted on 2018-11-28 19:10
  • MySQL事务介绍
    Posted on 2019-06-05 18:14
  • 程序员年中考试题-段子版
    Posted on 2021-06-23 15:57
  • BASE原则
    Posted on 2020-12-17 16:42