Repository navigation
docs: document where Lua m.log() messages goes - #7
Merged
Merged
Conversation
m.log(level, text) writes to the debug log, and only if SecDebugLogLevel is set to level or higher. ModSecurity v2 also copies levels 1-3 to the Apache error log, but libModSecurity v3 writes them only to the debug log, and not at all in a build configured with --disable-debug-logs. Users coming from v2, or looking in the nginx error log, didn't find their messages. Add a note after the first Lua example of SecRuleScript. Refs owasp-modsecurity/ModSecurity#3035
This was referenced Nov 1, 2026
fzipi
reviewed
Nov 2, 2026
fzipi
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @airween. The v3 half is right, but the v2 half needs a small fix, see inline.
What I checked:
- v3.
Lua::log()only callsms_dbg_a(), which writes to the debug log whenm_debugLevel >= level, and is an empty macro underNO_LOGS, which--disable-debug-logsdefines (configure.ac). So "only to the debug log" and the--disable-debug-logssentence are correct. - v2.
l_log()callsmsr_log(), andinternal_log_ex()(apache2/apache2_util.c) only returns early forlevel > 3. Messages at levels 1–3 are always sent to the Apache error log and added tomsr->alerts, even with noSecDebugLogandSecDebugLogLevel 0. That list becomes theMessage:lines in the audit log, andis_relevant++makes the transaction relevant forSecAuditEngine RelevantOnly. So "only if SecDebugLogLevel is set to level or higher" applies to the debug log only, and in v2 levels 1–3 also reach the audit log. The SecDebugLogLevel section already says they are "always copied" to the error log, so the note should match it.
Co-authored-by: Felipe Zipitría <3012076+fzipi@users.noreply.github.com>
fzipi
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Document where the messages of the Lua
m.log()function go, as agreed in owasp-modsecurity/ModSecurity#3035.m.log(level, text)writes to the debug log, and only ifSecDebugLogLevelis set tolevelor higher, with links toSecDebugLogandSecDebugLogLevel;--disable-debug-logs.Closes owasp-modsecurity/ModSecurity#3035
Further comments
Lua::log()(src/engine/lua.cc) callsms_dbg_a(), which writes only to the debug log, and only if the debug log level is at least the given level (headers/modsecurity/transaction.h). With--disable-debug-logs, configure definesNO_LOGS, andms_dbg_a()does nothing.l_log()(apache2/msc_lua.c) callsmsr_log(), which also sends levels 1-3 to the Apache error log (apache2/apache2_util.c). The existing SecDebugLogLevel text describes this for v2, so users coming from v2 expect the same in v3.AI disclosure
Made with help of Claude Code, Opus 5.5