The following tokens are available by default. Partly it is possible to pass an additional argument in square brackets.
:pid
– The process identifier.:tags
– The tags passed toserver.log
⇗/request.log
⇗.:level[field?]
- The logging Level. Iffield
is unset, get the label. Otherwise, iffield=code
, get the level itself.:time[format?]
- The current date and time in UTC. The available formats are:
- Default is the timestamp configured with
options.pino.timestamp
(971186136
) iso
for the common ISO 8601 date time format. Just works ifoptions.pino.timestamp
is unset (1970-01-12T05:46:26.136Z
)utc
for the common RFC 1123 date time format Just works ifoptions.pino.timestamp
is unset (Mon, 12 Jan 1970 05:46:26 GMT
)
- Default is the timestamp configured with
:message[field=msg]
- Themsg
ordata
field of the log. Just works with logged strings orserver.log
⇗/request.log
⇗ and ifoptions.hapiPino.mergeHapiLogData
is disabled (default). Otherwise pass a custom field with fallback to themsg
anddata
fields or use the:get[field]
token. Both alternatives expect dot notation paths.:get[field]
– The value related to the given path in dot notation. Like:message[field]
but without fallback.:error[field=message]
- Themessage
field of the error object. Alternatively pass a dot notation path to the token. Helpful paths aremessage
,stack
,type
,output
,isServer
andisBoom
. Additionally the pathsource
provides information about the error's source.:environment[field=NODE_ENV]
- An environment variable.
:requestId
- The unique request identifier.:responseTime
- The response time in milliseconds.:res[header]
- The givenheader
of the response.:req[header]
- The givenheader
of the request.:status
- The status code of the request/response.:method
- The http request method.:payload
- The request payload. Just works withoptions.hapiPino.logPayload = true
, it is enabled by default.
Please set
route.options.payload.output
todata
for full support of this token.
:remoteAddress
- The remote client IP address.:remotePort
- The remote client port.:url
- The parsed url of the request.
:host[field?]
– Information about the host. Get the host by default. This token is just available for theonPostStart
&onPostStop
events. It uses theserver.info
object ⇗, so it just works for a single connection. The available information are:
- Default is the host name of the connection (
localhost
) port
for the connection port (3000
)address
for the active IP address bound to the connection (127.0.0.1
)protocol
for the used protocol (http
)uri
for the complete host url (http://localhost:3000
)
- Default is the host name of the connection (
The following formats/presets are set by default:
Event | Preset | Emitter |
---|---|---|
log |
log.tinyjson |
server.log & internal server events |
request |
log.tinyjson |
request.log |
response |
response.tiny |
request is completed |
request-error |
error.tinyjson |
request failed (500 status code) & internal accept-encoding errors |
onPostStart |
server.info |
server is started |
onPostStop |
server.info |
server is stopped |
uncaught |
error.json |
uncaught error occurred |
:time :level :message
Example Output
1499260782451 info foobar
{ message::message, timestamp::time, level::level, environment::environment }
Example Output
{
"message": "foobar",
"timestamp": 1499260782451,
"level": "info",
"environment": "development"
}
:time :method :remoteAddress :url :status :payload (:responseTime ms)
Example Output
1499255578965 GET 127.0.0.1 / 200 {} (24 ms)
:time :level :error
Example Output
1499260782451 info Internal Server Error
{ error::error, timestamp::time, level::level, environment::environment }
Example Output
{
"error": "Internal Server Error",
"timestamp": 1499260782451,
"level": "info",
"environment": "development"
}
{ error::error, timestamp::time, level::level, environment::environment, source::error[source] }
Example Output
{
"error": "foobar is not defined",
"timestamp": 1499260782451,
"level": "info",
"environment": "development",
"source": "/Users/foobar/index.js:42:01"
}
{ error::error, timestamp::time, level::level, environment::environment, stack::error[stack] }
Example Output
{
"error": "foobar is not defined",
"timestamp": 1499260782451,
"level": "info",
"environment": "development",
"stack": "ReferenceError: foobar is not defined\n at Timeout.onTimeout..."
}
:time :level :message at: :host[uri]
Example Output
1499255572003 info server stopped at http://localhost:3000