Question: I find debugging monit to be a major pain. Monit's shell environment basically has nothing in it (no paths or other environment variables). Also, there are no log file that I can find.

The problem is, if the start or stop command in the monit script fails, it is difficult to discern what is wrong with it. Often times it is not as simple as just running the command on the shell because the shell environment is different from the monit shell environment.

What are some techniques that people use to debug monit configurations?

For example, I would be happy to have a monit shell, to test my scripts in, or a log file to see what went wrong.

Answer: 
I've had the same problem. Using monit's verbose command-line option helps a bit, but I found the best way was to create an environment as similar as possible to the monit environment and run the start/stop program from there.

```
# monit runs as superuser
$ sudo su

# the -i option ignores the inherited environment
# this PATH is what monit supplies by default
$ env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/sh

# try running start/stop program here
$

```

I've found the most common problems are environment variable related (especially `PATH`) or permission-related. You should remember that monit usually runs as root.

Also if you use `as uid myusername` in your monit config, then you should change to user `myusername` before carrying out the test.

I hope that helps.
By default, monit logs to your system message log and you can check there to see what's happening. 

Also, depending on your config, you might be logging to a different place

```
tail -f /var/log/monit

```

<http://mmonit.com/monit/documentation/monit.html#LOGGING>

Assuming defaults (as of whatever old version of monit I'm using), you can tail the logs as such:

**CentOS:**

```
tail -f /var/log/messages

```

**Ubuntu:**

```
tail -f /var/log/syslog

```

**Mac OSX**

```
tail -f /var/log/system.log

```

**Windows**

Here be Dragons

But there is a neato project I found while searching on how to do this out of morbid curiosity: <https://github.com/derFunk/monit-windows-agent>