0

my python web app writes logs to log file, and I want to be able to use goaccess for that. I read in documentation below is the list of format supported

# NCSA Combined Log Format
#log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"

# NCSA Combined Log Format with Virtual Host
#log-format %v:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u"

# Common Log Format (CLF)
#log-format %h %^[%d:%t %^] "%r" %s %b

# Common Log Format (CLF) with Virtual Host
#log-format %v:%^ %h %^[%d:%t %^] "%r" %s %b

# W3C
#log-format %d %t %h %^ %^ %^ %^ %r %^ %s %b %^ %^ %u %R

# Squid native log format
#log-format %^ %^ %^ %v %^: %x.%^ %~%L %h %^/%s %b %m %U

# AWS | Amazon CloudFront (Download Distribution)
#log-format %d\t%t\t%^\t%b\t%h\t%m\t%^\t%r\t%s\t%R\t%u\t%^

# Google Cloud Storage
#log-format "%x","%h",%^,%^,"%m","%U","%s",%^,"%b","%D",%^,"%R","%u"

# AWS | Elastic Load Balancing
#log-format %dT%t.%^ %^ %h:%^ %^ %T %^ %^ %^ %s %^ %b "%r" "%u"

# AWSS3 | Amazon Simple Storage Service (S3)
#log-format %^[%d:%t %^] %h %^"%r" %s %^ %b %^ %L %^ "%R" "%u"

# Virtualmin Log Format with Virtual Host
#log-format %h %^ %v %^[%d:%t %^] "%r" %s %b "%R" "%u"

I do not understand the above format codes, as in python loging file I specify log forma like this:

(asctime)s - %(name)s - %(levelname)s - %(message)s
Chang Zhao
  • 631
  • 2
  • 8
  • 24
  • There is a comprehensive explanation what each of those fields mean (and how to specify custom formats coming from your source) on GoAccess website: [CUSTOM LOG/DATE FORMAT](https://goaccess.io/man#custom-log) – zwer Sep 19 '18 at 08:45
  • @zwer so I have to put the specifier in the format I have logs coming out from python web app ?? – Chang Zhao Sep 19 '18 at 08:48
  • Pretty much. The alternative is to write a custom [`logging.Formatter`](https://docs.python.org/3/library/logging.html#logging.Formatter) to mimic one of the built-in log sources in GoAccess, but that's more effort than defining a source for your Python logs in GoAccess. – zwer Sep 19 '18 at 08:50
  • I tried testing with a simple log from python which looks like this: `19/Sep/2018 17:06:14 +0000 DEBUG` in my log file. and then when I try to open the log using `goaccess` I edited the LOG format to be like `%d %t %z %^`and in the date format which I specifed `%d:%b:%Y` and in time-format I specified: `%H:%M:%S %z` but I still get no valid hits. – Chang Zhao Sep 19 '18 at 09:15

0 Answers0