println to display information is possible, but quickly unpractical, as the logs of all processes get intermixed in your program’s output. Instead, you
should use SimGrid’s logging facilities, that are inspired from Log4J. This way, you can filter the messages at runtime, based on their
severity and their topic. There is four main concepts in SimGrid’s logging mechanism:
The category of a message represents its topic. These categories are organized as a hierarchy, loosely corresponding to SimGrid’s modules architecture. Existing categories are documented online, but some of them may be disabled depending on the compilation options. Use
--help-log-categories on the command line to see
the categories actually provided a given simulator.
The message priority represents its severity. It can be one of
critical. Every category has a configured
threshold, and only the messages with a higher severity are displayed (the others are not even evaluated). For example, you may want to see every debugging message of the Host
handling, while filtering out every other messages that are of a lesser priority than “error”. For that, use the following command line argument:
You can also change the layout used to format the messages, using format directives that are similar to the printf ones:
%r prints the time elapsed since the beginning of
%a gives the actor name, etc. Many such directives are available. You can have a specific layout per category, and it will be inherited by all
Finally, the appender actually displays the produced messages. SimGrid provides four appenders so far: the default one prints on stderr.
file writes to a given file,
rollfile does the same, but overwrites old messages when the file grows too large and
splitfile creates new files when the maximum size is reached. Each category can have
its own appender.