Linux 如何查看由 screen (screenlog.0) 生成的日志文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4420386/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I view a log file generated by screen (screenlog.0)
提问by rg88
So I just found out I can create log files of everything I do in screen (C-a H). Sounds like a nice way to keep track of potential goofs in a particular screen session. However, when I went to try it out the logfile is reported as being a binary file (and can't be viewed like a regular text as such). So am I missing something? A quick man page looksee and searching Google (and SO) turns up nothing about this.
所以我刚刚发现我可以创建我在屏幕(Ca H)中所做的一切的日志文件。听起来像是在特定屏幕会话中跟踪潜在错误的好方法。但是,当我去尝试它时,日志文件被报告为二进制文件(并且不能像常规文本一样查看)。所以我错过了什么吗?一个快速的手册页looksee和搜索谷歌(和SO)没有发现任何关于这个的信息。
So my question is: How do I generate plain text log files in screen?
所以我的问题是:如何在屏幕中生成纯文本日志文件?
Assuming the answer is "What a noob... how about you try making them? RTFM." my question becomes: How do I use less to view screen logfiles I've created (since less screenlog.0
does not work on a binary file)?
假设答案是“真是个菜鸟……你尝试制作它们怎么样?RTFM。” 我的问题变成:如何使用 less 来查看我创建的屏幕日志文件(因为less screenlog.0
不适用于二进制文件)?
EDIT:So cat
works fine but less
complains that the file is binary... why?
编辑:所以cat
工作正常但less
抱怨文件是二进制的......为什么?
SOLUTION:as jcomeau_ictx helpfully pointed out, you can view these logfiles fine with cat
or more
but with less
you must add the -r flag less -r screenlog.0
解决方案:正如 jcomeau_ictx 帮助指出的那样,您可以使用cat
或more
但less
必须添加 -r 标志来查看这些日志文件less -r screenlog.0
采纳答案by jcomeau_ictx
I just found a screenlog.0 on the net; it isplain text, with some escape sequences. Just 'cat' the file, you should be able to view it just fine.
我刚刚在网上找到了一个screenlog.0;它是纯文本,带有一些转义序列。只需'cat'文件,您应该可以很好地查看它。
[after more checking] Control-A H is what generates the screenlog on my system. And though 'cat' works, you'll miss a lot of data. Use 'more' instead of 'less' to interpolate the escape codes.
[经过更多检查] Control-A H 是在我的系统上生成屏幕日志的原因。尽管 'cat' 有效,你会错过很多数据。使用“更多”而不是“更少”来插入转义码。
回答by hbeck001
I found neither less nor more nor cat to be an ideal solution for viewing screenlog files. All "replay" some of the control character so that e.g. screen deletions as produced by "clear" (don't remember the corresponding control character) are beeing shown, hiding what has been cleared.
我发现 less 或 more 或 cat 都不是查看屏幕日志文件的理想解决方案。所有“重播”一些控制字符,以便例如由“清除”(不记得相应的控制字符)产生的屏幕删除被显示,隐藏已清除的内容。
What i know works great is: use "view" or "vi", it just shows the control character in escaped notation. Probably any other text editor works, too (not tested).
我知道效果很好的是:使用“view”或“vi”,它只显示转义符号中的控制字符。可能任何其他文本编辑器也可以工作(未测试)。
回答by Peter
-L logs to file, tail -f 'logfilename' to monitor this file
-L 记录到文件,tail -f 'logfilename' 监视这个文件