简体   繁体   English

对服务器的特定请求的日志分析/总和

[英]Log analysis/ sum of specific requests to the server

so lately i've been working on simple log analysis in python. I've got a log file and gotta do specific tasks on it.所以最近我一直在 python 中进行简单的日志分析。我有一个日志文件,必须对其执行特定任务。 The first one is to print out the date that had most requests to a specific url. The date format is YYYY-MM-DD.第一个是打印出对特定 url 请求最多的日期。日期格式为 YYYY-MM-DD。 If i get the first one down imma do rest myself, just don't know how to start.如果我把第一个弄下来我自己做 rest,只是不知道如何开始。 I've already imported the file.我已经导入了文件。

The question is, how do i define a specific format (for example XXXX-XX-XX) and compare it with other ones?问题是,我如何定义特定格式(例如 XXXX-XX-XX)并将其与其他格式进行比较? Would like to see some real code that does it.希望看到一些真正的代码。 Thanks谢谢

import logging

logger = logging.getLogger(__name__)

logging.basicConfig(level=logging.DEBUG, datefmt = '%y-%b-%d %H:%M:%S', format = "[%(asctime)s : %(name)s - %(message)s]")

def printName():

    name = input("Enter Ur Name: ")

    print(f"Entered Name: {name}")

    logging.debug(f"{name} printed his/her name")

printName()

NB:注意:

You can integrate these logs directly into your log files using "filename" parameter您可以使用“文件名”参数将这些日志直接集成到您的日志文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM