logfile

How to show the line number from the file invoking the logger, not the logger file itself?

How to show the line number from the file invoking the logger, not the logger file itself? Question: I have a custom logging class, which has the following format: log_format = "%(asctime)s.%(msecs)d %(levelname)-8s [%(processName)s] [%(threadName)s] %(filename)s:%(lineno)d — %(message)s" My project tree looks something like this: . ├── exceptions.py ├── logger.py ├── settings.py └── main.py In …

Total answers: 1

Convert Logfile to CSV

Convert Logfile to CSV Question: I would like to request assistance with a Python script to convert a logfile into a csv file. I am looking for the Python code to do this. My input information looks as follows: Exception: Cannot open file "C:ProgramDataPresenceLogpco_nhp01_CT_1800.log". Access is denied Original message: [27/01/2023 12:37:44:675] TID:[14588] ENTER FUNCTION SetActive …

Total answers: 2

converting txt data (from log file) into json using python?

converting txt data (from log file) into json using python? Question: I have a log file which has the format as shown below: parsed: {‘priority’: ’14’, ‘timestamp’: ‘2021-04-13 13:42:07’, ‘hostname’: ‘invi-dev-gw2’, ‘rootname’: ‘root’, ‘pid’: ‘27889’, ‘message’: ‘Session STARTED – Client[ID:8242, Physical: 111.119.187.47, Virtual: 10.1.0.66] <–> Service[Name:Attendance1, ID:704, Physical: 192.168.3.18, Virtual: 10.1.0.67]’} parsed: {‘priority’: ’15’, ‘timestamp’: …

Total answers: 1

Logging to two files with different settings

Logging to two files with different settings Question: I am already using a basic logging config where all messages across all modules are stored in a single file. However, I need a more complex solution now: Two files: the first remains the same. The second file should have some custom format. I have been reading …

Total answers: 2

Get last n lines of a file, similar to tail

Get last n lines of a file, similar to tail Question: I’m writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item at the bottom. So I need a tail() …

Total answers: 34