Logs
Dgraph logs requests for queries and mutations, and also provides audit logging capabilities with a Dgraph Enterprise license
We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
Dgraph logs requests for queries and mutations, and also provides audit logging capabilities with a Dgraph enterprise license.
Dgraph’s log format comes from the glog library and is formatted as follows:
The fields are defined as follows:
Field | Definition |
---|---|
L | A single character, representing the log level (such as ‘I’ for INFO) |
mm | Month (zero padded; ie May is ‘05’) |
dd | Day (zero padded) |
hh:mm:ss.uuuuuu | Time in hours, minutes and fractional seconds |
threadid | Space-padded thread ID as returned by GetTID() |
file | Filename |
line | Line number |
msg | User-supplied message |
Log verbosity
To increase log verbosity, set the flag -v=3
(or -v=2
) which enables verbose
logging for everything. You can set this flag on both Zero and Alpha nodes.
Request logging
Request logging, sometimes called query logging, lets you log queries and
mutations. You can dynamically turn request logging on or off. To toggle request
logging on, send the following GraphQL mutation to the /admin
endpoint of an
Alpha node (for example localhost:8080/admin
):
logRequest
in versions prior to v23.The response should look like the following:
The Alpha node prints the following INFO
message to confirm that the mutation
has been applied:
When enabling request logging this prints the requests that Dgraph Alpha receives from Ratel or other clients. In this case, the Alpha log prints something similar to:
As you can see, we got the query that Alpha received. To read it in the original
DQL format just replace every \n
with a new line, any \t
with a tab
character and \"
with "
:
Similarly, you can turn off request logging by setting logRequest
to false
in the /admin
mutation.
Audit logging (enterprise feature)
With a Dgraph enterprise license, you can enable audit logging so that all requests are tracked and available for use in security audits. To learn more, see Audit Logging.
Was this page helpful?