windows动态查看最新日志信息

2019-02-23 14:52 By "Powerless" 2855 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

  • 必学十大经典排序算法,看这篇就够了
    Posted on 2019-11-18 16:30
  • PHP设计模式 - 委托模式
    Posted on 2019-04-25 16:15
  • 初识七层、五层、四层网络协议
    Posted on 2021-04-09 16:52
  • PHP7不兼容性
    Posted on 2018-03-07 15:59
  • 浏览器访问网站经历的步骤-Html
    Posted on 2018-11-28 18:48
  • PHP练习-无重复字符的最长子串
    Posted on 2020-09-17 18:03
  • QPS、TPS、RT、吞吐量到底是什么
    Posted on 2020-02-02 01:15
  • ACID原则
    Posted on 2020-12-17 16:36