Search for number in a text file?

Viewed 1195

I try to get a number from my logfile. This number comes after every "current store usage is ". How can I do that? Can I use the re module?

Line from the logfile

2017-05-30 12:01:03,168 | WARN  | Store limit is 102400 mb (current store usage is 0 mb). The data directory: /opt/apache-activemq-5.12.0/bin/linux-x86-64/../../data only has 6887 mb of usable space - resetting to maximum available disk space: 6887 mb | org.apache.activemq.broker.BrokerService | WrapperSimpleAppMain

My code

def log_parser():
    palab2 = "WARN"
    logfile = open("/opt/apache-activemq-5.12.0/data/activemq.log", "r")
    contenlog = logfile.readlines()
    logfile.close()
    for ligne in contenlog:
        if palab2 in ligne:
            print ("Probleme : " + ligne)
3 Answers
Related