How I can debug or view logs of openmrs

I added System.out.println(“text”) in controller of bahmnicore-omod. After updating module in openmrs. I try to view log with command : tail -f openmrs.log. But it does not trace text of System.out.println command.

Can you please specify the class name and also possibly snippet of your changes?

Hi @mjsanish, Please follow below steps.

  1. Start OpenMRS in debug mode i.e service openmrs debug
  2. If your IDE is IntelliJ, then follow this link for setting remote server debug.
1 Like
  • First I changed in bahmni-core/bahmnicore-omod/src/main/java/org/bahmni/module/bahmnicore/web/v1_0/controller/ file as following:
  @RequestMapping(method = RequestMethod.GET, value = "globalproperty")
    public Object retrieve(@RequestParam(value = "property", required = true) String name) {
       // added debuging code
        LOGGER.log(Level.WARNING, "this is warning");
        System.out.println("------------------------ start -------------------------");

        return administrationService.getGlobalProperty(name);
  • Run mvn at bahmni-core/bahmnicore-omod
   $ mvn clean install
  • Then go to bahmni-vagrant/ and run command
  $ vagrant up
  • Copy bahmnicore-omod-0.86-SNAPSHOT.omod to vagrant
$ scp  -i ~/.vagrant.d/insecure_private_key -o ConnectTimeout=5 bahmni-core/bahmnicore-omod/target/bahmnicore-omod-0.86-SNAPSHOT.omod vagrant@
  • Connect to vagrant
  $ vagrant ssh
  • Then inside vagrant run following commands
  $ sudo service openmrs stop
// Remove previous bahmnicore-0.86-SNAPSHOT.omod
  $ sudo rm -f /opt/openmrs/modules/bahmnicore*.omod 
# Added new bahmnicore-0.86-SNAPSHOT.omod
  $ sudo cp -f /tmp/deploy_bahmni_core/bahmnicore-0.86-SNAPSHOT.omod /opt/openmrs/modules
# Run openmrs in debug mode
  - sudo service openmrs debug
# trace openmrs log
  - tail -f /opt/openmrs/openmrs.log
 LOGGER.log(Level.WARNING, "this is warning");
        System.out.println("------------------------ start -------------------------");

How can I debug?

Please connect to you remote server thought debug from your IDE to debug as mentioned in my previous reply and use below statement to log.