function setModelLoggingInfo(obj)
%

%   Copyright 2014 The MathWorks, Inc.

    topLevelModelH = obj.ModelHsInMdlRefTree(1);
    mi = Simulink.SimulationData.ModelLoggingInfo(get_param(topLevelModelH,'Name'));
    mi.LoggingMode = 'OverrideSignals';
    
    numPorts = length(obj.PortHsToLog);
    numDSMs = length(obj.dsmHsToLog);
    for idx=1:numPorts
        mi.Signals(idx) = ...
            Simulink.SimulationData.SignalLoggingInfo(...
            getfullname(get_param(obj.PortHsToLog(idx),'Parent')), ...
            get_param(obj.PortHsToLog(idx),'PortNumber'));
    end
    for idx=1:numDSMs
        mi.Signals(idx+numPorts) = ...
            Simulink.SimulationData.SignalLoggingInfo(...
            getfullname(obj.dsmHsToLog(idx)));
    end
    
    for idx=1:numPorts        
        mi.Signals(idx).LoggingInfo.NameMode = true;
        mi.Signals(idx).LoggingInfo.LoggingName = sprintf('%s%d',obj.SignalLoggerPrefix, idx);
    end
    for idx=1:numDSMs
        mi.Signals(idx+numPorts).LoggingInfo.NameMode = true;
        mi.Signals(idx+numPorts).LoggingInfo.LoggingName = sprintf('%s%d',obj.SignalLoggerPrefix, idx+numPorts);
    end    
    
    set_param(topLevelModelH, 'DataLoggingOverride', mi);
    set_param(topLevelModelH, 'LoggingToFile', 'off');
end