Answered my own question: of course after trying to get it to work for an hour or two, just minutes after posting this question I got it working:
#[test_log::test(tokio::test)]
async fn test_dynamic_logging3() {
debug!("This will be ignored");
let debug_subscriber = tracing_subscriber::fmt::Subscriber
::builder()
.with_max_level(tracing::Level::DEBUG)
.with_test_writer()
.finish();
tracing::subscriber::with_default(debug_subscriber, || {
debug!("This will be logged");
});
debug!("This will be ignored");
}