# verify current setting
sysctl kernel.core_pattern
You can change default core dump as below:
echo '/var/log/testprogram/core_%e.%p' | sudo tee /proc/sys/kernel/core_pattern
# verify the setting
sysctl kernel.core_pattern
Now, all the programs if any major faults, will generate coredump in the above directory configured.
core_%e_%p
Here %e - program name , %p - pid of process
Check, man core for more details.
This article discussed about how to compress the core file generated:
https://docs.solace.com/Configuring-and-Managing/SW-Broker-Specific-Config/Docker-Tasks/Config-Core-Dump-Mgmt.htm