A computer system configured for activity-based sampling of diagnostic data, the system comprising: at least one processor; a memory in operable communication with the processor(s); and a set of event definitions residing in the memory and defining events; an application residing in the memory and having application code which is configured to invoke at least one log-event procedure; a current activity-id which specifies whether an activity of the application is currently designated, and when some activity is currently designated also specifies which activity is currently designated; and a logger residing in the memory and having logger code which is configured to associate a thread-id with an activity id and to interact with the processor and memory to check a set of specified logging conditions and send a log entry to a log in response to invocation of a log-event procedure when at least one specified logging condition is satisfied; the logger including a set of log-enabled activities, and also including a set of one or more start-events with respective sampling frequency conditions, each start-event also being an event which is defined in the set of event definitions; the specified logging conditions including (a) a first condition specifying that the current activity-id is present in the set of log-enabled activities, and also including (b) a second condition specifying that the current activity-id is absent from the set of log-enabled activities, that the log-event procedure identifies a start-event, and that the invocation of the log-event procedure is consistent with the sampling frequency condition of the start-event; and a child-activity procedure invocation which is configured to notify the logger that a current activity is creating a child activity, and wherein the logger code is configured to automatically add the child activity to the set of log-enabled activities in response to the child-activity procedure invocation. at least one processor; a memory in operable communication with the processor(s); and a set of event definitions residing in the memory and defining events; an application residing in the memory and having application code which is configured to invoke at least one log-event procedure; a current activity-id which specifies whether an activity of the application is currently designated, and when some activity is currently designated also specifies which activity is currently designated; and a logger residing in the memory and having logger code which is configured to associate a thread-id with an activity id and to interact with the processor and memory to check a set of specified logging conditions and send a log entry to a log in response to invocation of a log-event procedure when at least one specified logging condition is satisfied; the logger including a set of log-enabled activities, and also including a set of one or more start-events with respective sampling frequency conditions, each start-event also being an event which is defined in the set of event definitions; the specified logging conditions including (a) a first condition specifying that the current activity-id is present in the set of log-enabled activities, and also including (b) a second condition specifying that the current activity-id is absent from the set of log-enabled activities, that the log-event procedure identifies a start-event, and that the invocation of the log-event procedure is consistent with the sampling frequency condition of the start-event; and a child-activity procedure invocation which is configured to notify the logger that a current activity is creating a child activity, and wherein the logger code is configured to automatically add the child activity to the set of log-enabled activities in response to the child-activity procedure invocation.