显示特定时间的日志 [英] Display logs of a specific time

查看:87
本文介绍了显示特定时间的日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在给定的时间内显示计算机中的所有日志
apache tomcat网页中的


显示 start time中的日志到<大>结束时间



我尝试过的方法:



我知道该怎么做

请帮帮我

我刚刚开始使用tomcat和日志文件

I want to display all the logs in the computer for the given period of time
in apache tomcat webpage
display the logs from start time to end time which should be got from the user

What I have tried:

I did know what to do
please help me
I am just starting with tomcat and log files

推荐答案

您没有指定要使用的工具或编程语言。



工具



有多种工具可供查看日志文件。只需在网上搜索日志文件查看器或日志文件分析器等内容。



编程语言



逐行处理日志文件。这可以在逐行读取时或通过将整个内容读入分配的缓冲区并对其进行操作来完成。两者都是常见的操作,其中可以在网络中找到许多示例。



编写一个函数来从日志文件的一行获取时间戳。如何执行此操作取决于日志文件的格式。如果日志文件包含 ISO 8601 - 维基百科 [ ^ ]日期时间,您可以将其作为字符串(ISO 8601日期时间可以比较为字符串,以检查在特定日期时间之前或之后)。否则你必须将它们转换为二进制日期时间格式。



然后跳过开始日期之前的所有行。显示行直到达到结束日期。
You did not specified what kind of tool or programming language you want to use.

Tools

There are multiple tools to view log files. Just search the web for something like "log file viewer" or "log file analyzer".

Programming language

Process the log file line by line. This can be done while reading line wise or by reading the whole content into an allocated buffer and operating on that. Both are common operations where many examples can be found in the web.

Write a function to get the timestamp from a line of the log file. How to do this depends on the format of the log file. If the log file contains ISO 8601 - Wikipedia[^] datetimes, you can get it as string (ISO 8601 datetimes can be compared as strings to check for being before or after a specific datetime). Otherwise you have to convert them to a binary datetime format.

Then skip all lines that are before the start date. Display the lines until the end date is reached.


这篇关于显示特定时间的日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆