KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write( "src/main/resources/r1.drl", str );
ks.newKieBuilder( kfs ).buildAll();
KieBase kbase = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).getKieBase();
KieSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
SingleSessionCommandService sscs = (SingleSessionCommandService)
((CommandBasedStatefulKnowledgeSession) ksession).getCommandService();
sscs.addInterceptor(new LoggingInterceptor());