logging for headless

34 views
Skip to first unread message

Neal Wagner

unread,
Oct 6, 2021, 11:20:44 AM10/6/21
to netlogo-devel
Hi,

How can I enable logging for running netlogo headless? Thanks.

Neal

jeremy...@northwestern.edu

unread,
Oct 6, 2021, 12:50:32 PM10/6/21
to netlogo-devel
Enabling logging through the preferences menu in the GUI should also enable it when running headlessly through the included script and when running through sbt as it's stored per-user.  Since this is the devel group I'm not 100% which headless method you are referring to, though.  If you can provide more details on what you are doing and why, I or someone else might be able to provide more helpful information.  Thanks.

-Jeremy

jeremy...@northwestern.edu

unread,
Oct 7, 2021, 4:39:37 PM10/7/21
to netlogo-devel
Hey Neal,

So this wound up a little more complicated than I expected.  As usual.

I was thinking you wanted to enable headless logging to get info on global variable changes and turtle/link births and deaths, correct?  I don't see much point in trying to get UI events like widgets added, command center code entered, as they will not occur headlessly.  I was then looking to run a test to make sure I gave you good advice when I found something strange.  It appears logging of turtle births and deaths and global variable changes hasn't worked since at least version 5.0 of NetLogo.  The code to perform the logging was removed in that release and never re-added.  I don't think logging of links was ever added properly, but either way it also does not work now.  I'm going to make a note to have our team look into getting this fixed.  It must not be a much-used feature since we have no other reports on it.

But with that being that case I can't see a lot of benefit to enabling logging in your headless application of NetLogo, as no worthwhile information will be presented.  If you want to try anyway, here is the code the GUI app uses to setup logging:  https://github.com/NetLogo/NetLogo/blob/hexy/netlogo-gui/src/main/app/App.scala#L518-L521  But again, the `HeadlessWorkspace` doesn't even take in a listener as the `GUIWorkspace` does, so it won't use that to log anything at all.  Only things that log themselves globally would get recorded, and I don't see any of those that aren't UI elements.

To switch gears then, I'd recommend using BehaviorSpace to get information out of a headless model run.  If you need to control what data is extracted regardless of the model (you don't want to hand-edit multiple models to work in your new program), you can do so either by generating the XML file to use, or by creating a `LabProtocol` and running BehaviorSpace through code.  See [the answer on this StackOverflow question] for more details on that.

If BehaviorSpace doesn't sound like it'll fit your use case, please elaborate a little more and maybe we can come up with something else.

-Jeremy
Reply all
Reply to author
Forward
0 new messages