
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
good-apache-log
Advanced tools
Apache httpd log files for Hapi web servers
Lead Maintainer: Jason Smith
Good-Apache-Log makes Hapi write server logs in the server logs in the Apache combined or common log format, via the Good reporting framework.
The Apache format? You know: this one—the ubiquitous format every tool on the Internet can process.
127.0.0.1 - - [07/Aug/2015:14:01:21 +07:00] "GET / HTTP/1.1" 200 39 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.12"
127.0.0.1 - - [07/Aug/2015:14:01:21 +07:00] "GET /favicon.ico HTTP/1.1" 200 39 "http://localhost:8080/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.12"
127.0.0.1 - - [07/Aug/2015:14:01:31 +07:00] "GET /product/280 HTTP/1.1" 200 45 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36"
127.0.0.1 - - [07/Aug/2015:14:01:31 +07:00] "GET /favicon.ico HTTP/1.1" 200 41 "http://localhost:8080/product/280" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36"
Good-Apache-Log appends to a log file, and it it re-opens the log file when you send SIGHUP. This makes it very easy to implement log rotation, using logrotate, for example.
In other words, Good-Apache-Log makes your Hapi server a much more friendly dev-ops citizen by supporting standard logging formats and behavior.
Install this package with npm:
$ npm install good-apache-log
Place Good-Apache-Log as a reporter in your Good configuration.
var logFile = "my-server.log"
var reporters = [ {reporter:GoodApacheLog, events:{response:'*'}, config:logFile} ]
var goodPlugin = {register:Good, options:{responsePayload:true, reporters:reporters}}
server.register([goodPlugin], function(er) {
if (!er)
console.log('GoodApacheLog is registered.')
})
Now you will see a familiar face in my-server.log.
Note, if you set "responsePayload": true in the Good config, then your logs will show the response payload size (the %b format string). Otherwise, the payload size will be logged as -.
See test/server.js for an example of a very simple Hapi server that uses GoodApacheLog.
Usually, you can set the reporter config value to the path to your log file, or to an existing stream (eg: console.stdout). Hapi will now automatically append logs to that file/stream, and for a file if you send a HUP signal to your server, it will re-open that file.
However, for more detailed control, config can be an object with these keys:
"combined"; see Log Formats below"\n"true, Good-Apache-Log will listen to SIGHUP and re-open its log file; default is trueSimilar to the Apache httpd server, the format value allows you to specify your log file format. Either choose a "nickname" or provide your own format string.
Note Not all format strings are supported yet. If you need one, please create an issue or pull request.
For example to make a simple log file of status codes and user-agents:
var reporters = [
{
reporter: GoodApacheLog,
events: {response:'*'},
config: {file:"httpd.log", format:"%s %{User-agent}i"}
}
]
Example log file:
200 Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:39.0) Gecko/20100101 Firefox/39.0
404 Mozilla/5.0 (iPhone; CPU iPhone OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12H143 Safari/600.1.4
500 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36
200 Mozilla/5.0 (iPhone; CPU iPhone OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12H143 Safari/600.1.4
301 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36
These nicknames, taken from from the Apache httpd documentation, expand to the most commonly-used log formats.
%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"%h %l %u %t "%r" %>s %b%{Referer}i -> %UFAQs
Apache "combined" log files for Hapi
We found that good-apache-log demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.