Firstly, the following page indicates that you should set "LoggingMode" to "OverrideSignals" to control the logging mode for the top level model and all referenced models.
It is also possible to use a mix of override signal logging settings and model-specified (ignore override) logging settings using an cell array for "LogAsSpecifiedByModels".
Secondly, the following example walks through how you can selectively modify the "ModelLoggingInfo" for specific models in a reference hierarchy, and "DataLogging" settings for specific signals within those models.
Pay particular attention to the "Log a Subset of Signals" example. It uses "findSignal" and a loop to change the "DataLoggingOverride" settings for each signal.
mi = Simulink.SimulationData.ModelLoggingInfo.createFromModel(...
'ex_bus_logging');
pos = mi.findSignal({'ex_bus_logging/CounterA' ...
'ex_mdlref_counter_bus/Bus Creator'}, 1)
for idx=1:length(mi.Signals)
mi.Signals(idx).LoggingInfo.DataLogging = (idx == pos);
end
To apply the override settings, you use the following syntax:
set_param(ex_bus_logging,'DataLoggingOverride', mi);
To save the "Override Signals" configuration to apply it later, use "get_param" as follows:
>>si = get_param(bdroot,'DataLoggingOverride')
Best Answer
We have disabled logging controls inside libraries so that you MUST log in the model and not the library. For compatibility, we still support APIs for logging in library.
The problem in this case is that logging is already enabled in the library. That means even if you turn it off in the model, the next time you load the model the logging settings get re-applied from the library. That is to support loading models in earlier releases.
To fix the problem, first you need to disable all logging in the library:
Now you can save the library and reopen them model. To workaround the problem, you may need to first remove all redundant logging settings in the model in the same way:
After doing this, you should be able to log and unlog signals in the model, including those within library instances without any problems.