In apex, can you dynamically check if the current user has an active debug session (i.e. Setup -> Monitoring -> Debug Logs)?

I looked at the DebuggingHeader, but it doesn't quite do the trick



Sure we can use the below query:

SELECT Id,TracedEntityId FROM TraceFlag where TracedEntity.type = 'user'

also, you can run the query without any conditions and filter various traceflags by iteration after a null check on them..

| improve this answer | |
  • Thanks... can you use TraceFlag in Apex, or is when you're using the Tooling API? – PartOfTheOhana Mar 10 at 17:14
  • I was able to use it in apex execution it worked fine for me ☺️ – Abhijith E Mar 11 at 0:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.