You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.0 KiB

9 years ago
  1. # Logging
  2. By default, local-web-server outputs a simple, dynamic statistics view. To see traditional web server logs, use `--log-format`:
  3. ```sh
  4. $ ws --log-format combined
  5. serving at http://localhost:8000
  6. ::1 - - [16/Nov/2015:11:16:52 +0000] "GET / HTTP/1.1" 200 12290 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2562.0 Safari/537.36"
  7. ```
  8. The format value supplied is passed directly to [morgan](https://github.com/expressjs/morgan). The exception is `--log-format none` which disables all output.
  9. # Visualisation
  10. ## Goaccess
  11. To get live statistics in [goaccess](http://goaccess.io/), first create this config file at `~/.goaccessrc`:
  12. ```
  13. time-format %T
  14. date-format %d/%b/%Y
  15. log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
  16. ```
  17. Then, start the server, outputting `combined` format logs to disk:
  18. ```sh
  19. $ ws -f combined > web.log
  20. ```
  21. In a separate tab, point goaccess at `web.log` and it will display statistics in real time:
  22. ```
  23. $ goaccess -p ~/.goaccessrc -f web.log
  24. ```
  25. ## Logstalgia
  26. local-web-server is compatible with [logstalgia](http://code.google.com/p/logstalgia/).
  27. ### Install Logstalgia
  28. On MacOSX, install with [homebrew](http://brew.sh):
  29. ```sh
  30. $ brew install logstalgia
  31. ```
  32. Alternatively, [download a release for your system from github](https://github.com/acaudwell/Logstalgia/releases/latest).
  33. Then pipe the `logstalgia` output format directly into logstalgia for real-time visualisation:
  34. ```sh
  35. $ ws -f logstalgia | logstalgia -
  36. ```
  37. ![local-web-server with logstalgia](https://raw.githubusercontent.com/75lb/local-web-server/master/doc/img/logstagia.gif)
  38. ## glTail
  39. To use with [glTail](http://www.fudgie.org), write your log to disk using the "default" format:
  40. ```sh
  41. $ ws -f default > web.log
  42. ```
  43. Then specify this file in your glTail config:
  44. ```yaml
  45. servers:
  46. dev:
  47. host: localhost
  48. source: local
  49. files: /Users/Lloyd/Documents/MySite/web.log
  50. parser: apache
  51. color: 0.2, 0.2, 1.0, 1.0
  52. ```