0

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. The first one is to print out the date that had most requests to a specific url. The date format is YYYY-MM-DD. If i get the first one down imma do rest myself, just don't know how to start. 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? Would like to see some real code that does it. Thanks

  • what have you tried so far ? https://stackoverflow.com/help/minimal-reproducible-example – D.L Sep 30 '22 at 19:11
  • question already exists: https://stackoverflow.com/questions/1937622/convert-date-to-datetime-in-python – D.L Sep 30 '22 at 19:11

1 Answers1

-1
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

Blastfurnace
  • 18,411
  • 56
  • 55
  • 70