The Tooling API brings a new object with it, that allows me to create Apex Logs programmatically. It's called TraceFlag. I tried to implement it in my na15 org (28.0) but i get a
No access to entity: TraceFlag
warning.
I just use Developer's Guide code:
TraceFlag traceFlag = new TraceFlag();
traceFlag.ApexCode = 'Finest' ;
traceFlag.ApexProfiling = 'Finest' ;
traceFlag.Callout = 'Info' ;
traceFlag.Database = 'Finest' ;
traceFlag.System = 'Debug' ;
traceFlag.Validation = 'Info' ;
traceFlag.Visualforce = 'Info' ;
traceFlag.Workflow = 'Info' ;
//set an expiration date
traceFlag.ExpirationDate = myTimestamp;
//set the ID of the user to monitor
traceFlag.TracedEntityId = runAs.Id ;
//call the create method
TraceFlag[] traceFlags =new TraceFlag[] {traceFlag};
SaveResult[] traceResults = sforce.create(traceFlags);
for ( int i = 0; i < traceResults.Length; i++)
{
if (traceResults[i].success) {
System.debug( 'Successfully created trace flag: ' + traceResults[i].id);
}
else {
System.debug( 'Error: could not create trace flag ' );
System.debug( ' The error reported was: ' +
traceResults[i].errors[0].message + '\n' );
}
}
Do I need to create it via REST API?