Logging to ZAP core logger in Script Console

258 views
Skip to first unread message

Binhomolayzu Rekt

unread,
Jul 5, 2021, 6:47:32 AM7/5/21
to OWASP ZAP User Group
Hello,

Is it possible to use the ZAP core logger in Javascript scripts?

Or maybe get the output of script console and export it as `zap-scripts.log`

Thanks,
Binhomolayzu

Binhomolayzu Rekt

unread,
Jul 6, 2021, 10:14:17 AM7/6/21
to OWASP ZAP User Group
Hi!

Any updates, please? Do let me know if this isn't possible.

Many Thanks,
Binhomolayzu

Simon Bennetts

unread,
Jul 6, 2021, 10:24:32 AM7/6/21
to OWASP ZAP User Group
Hi,

Yes, all of the scripting languages can call Java class methods and they will be able to log in the the same way as the java classes.
We have this related script which allows you to turn debug logging on: https://github.com/zaproxy/community-scripts/blob/main/standalone/enableDebugLogging.js

I just ran this standalone script:

var LoggerManager = Java.type("org.apache.logging.log4j.LogManager")
var log = LoggerManager.getLogger("script")
log.info("Example info message")

And got this in the zap.log file:

419421 [ZAP-ScriptExecutor-log] DEBUG org.zaproxy.zap.extension.script.ExtensionScript - invokeScript log
419429 [ZAP-ScriptExecutor-log] INFO  script - Example info message

Cheers,

Simon

Binhomolayzu Rekt

unread,
Jul 6, 2021, 10:34:29 AM7/6/21
to OWASP ZAP User Group
Hi Simon,

Thank you so much! This is precisely what i was looking for.

Best regards,
Binhomolayzu

Michael Endrizzi

unread,
Dec 15, 2023, 2:41:45 AM12/15/23
to ZAP User Group
Thanks...was looking for this. Important for cicd pipeline debugging.
Reply all
Reply to author
Forward
0 new messages