You may use the tlm recorder of the SystemC components lib (SCC, esp. here: https://git.minres.com/SystemC/SystemC-Components/src/branch/master/incl/scv4tlm). This writes into a text database (the SCV default). You can view this e.g. with Impulse (https://toem.de/index.php/projects/impulse) or SCViewer (https://git.minres.com/VP-Tools/SCViewer, binaries here: https://github.com/Minres/SCViewer/releases).
Basically you instantiate scc::tlm2_recorder_module and connect it's initiator and target sockets. to your target and initiator socket. Your sc_main should then look like:
int sc_main(int argc, char *argv[]) {
scv_startup();
scv_tr_text_init();
scv_tr_db db("my_db.txlog");
scv_tr_db::set_default_db(&db);
dut_mod dut("dut");
sc_start(1.0, SC_MS);
return 0;
}
The database is closed upon destruction of the db object.
Best regards