Logging statement¶
The logging statement prints information during procedure execution for debugging or monitoring purposes. You can specify the log level, location, and content based on the context of the procedure you create.
The log levels, sorted from lowest to highest severity, are DEBUG<INFO<WARN<ERROR<FATAL. The corresponding keywords in the log statement are:
LOG_DEBUG: Specify this level to print debug information. Disabled by default.LOG_INFO: Specifies this level to print regular operational information that indicates procedures are working as expected. Enabled by default.LOG_WARN: Specify this level to print warnings about potential problems. Enabled by default.LOG_ERROR: Specify this level to print errors that disrupt core functionality. Enabled by default.LOG_FATAL: Specify this level to print fatal errors that halt the procedure. Enabled by default. This level of log will terminate the procedure execution.
By default, INFO is set as the minimum log level so that only logs at that level or higher can be printed. To change the minimum level, see Configure the minimum log level.
Note
Each procedure is limited to a maximum log size of 64MB. Minimize logging in PER NODE or PER PATH clauses when processing large graphs to avoid exceeding this limit.
Syntax¶
- log_statement
log_statement ::= ('LOG_DEBUG' | 'LOG_INFO' | 'LOG_WARN' | 'LOG_ERROR' | 'LOG_FATAL') '(' log_message (',' log_message)* ')'
Parameters¶
log_message¶
The message module in the log. Multiple modules can form a log, separated by commas (,). Each module can contain a variable name or literal.
Supported variable types (must be defined before using the log statement):
Supported literal types:
- Numeric
- Character string (must be enclosed by double quotes
") - Boolean
- Temporal
- List
Examples¶
The following example is based on the temporary graph #movie_temporary_graph created in CREATE TEMPORARY GRAPH.
Print logs with a variable¶
'''
USE #movie_temporary_graph {
VALUE w SumAgg<INT> = 0
MATCH ()-[e:Watch]-()
PER PATH {
SET @w += 1
}
LOG_INFO("Finish Iteration")
LOG_WARN("Final w: ", @w)
RETURN @w AS watch_count
}
'''
Return:
+-------------+
| watch_count |
+-------------+
| 7820 |
+-------------+
Log:
2025-07-23T07:45:28.432266 INFO - Finish Iteration
2025-07-23T07:45:28.432531 WARN - Final w: 7820
Print a FATAL log¶
'''
USE #movie_temporary_graph {
LOG_DEBUG("This is a debug log")
LOG_INFO("This is an info log")
LOG_WARN("This is a warning log")
LOG_ERROR("This is an error log")
LOG_FATAL("This is a fatal log")
}
'''
Return:
Error: [NP101]: Procedure error: 2025-07-22T06:38:13.247332 FATAL - This is a fatal log
The preceding statement terminates the procedure execution, returns an error, and prints a FATAL log.