# Location of openmrs.log

**URL:** <https://talk.openmrs.org/t/location-of-openmrs-log/34562>\
**Category:** Ask OpenMRS\
**Created:** [September 2, 2021, 12:54pm UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562 "2021-09-02T12:54:47Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![alwaysskint](https://talk.openmrs.org/letter_avatar/alwaysskint/32/6_449c533f586939b6e5f246632a46421f.png) [@alwaysskint](https://talk.openmrs.org/u/alwaysskint)\
**Post date:** [September 2, 2021, 12:54pm UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/1 "2021-09-02T12:54:47Z")

</div>

Reference Application 2.11 Linux

Now that I’ve got OpenMRS running more secure with SSL, I’m trying to enhance security by running it as a user (tomcat) rather than root. Along with a few other issues, the main one I have just now is the following error:

`localhost-startStop-1 ERROR RollingFileManager (openmrs.log) java.io.FileNotFoundException: openmrs.log (Permission denied)`

The problem is that there’s no indication of where it is trying to locate this file. Any clues, as I’ve tried various locations and setting environment variables?

---

<div class="post-metadata">

**Author:** ![jwnasambu](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jwnasambu/32/13543_2.png) [@jwnasambu](https://talk.openmrs.org/u/jwnasambu)\
**Post date:** [September 2, 2021, 2:08pm UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/2 "2021-09-02T14:08:12Z")

</div>

@alwaysskint Congratulations for the milestone! kindly have you shared the entire error logs?

---

<div class="post-metadata">

**Author:** ![alwaysskint](https://talk.openmrs.org/letter_avatar/alwaysskint/32/6_449c533f586939b6e5f246632a46421f.png) [@alwaysskint](https://talk.openmrs.org/u/alwaysskint)\
**Post date:** [September 2, 2021, 2:58pm UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/3 "2021-09-02T14:58:17Z")

</div>

Hi,

No, because most of the 5MB catalina.out log is irrelevant, as it begins from three days ago. 😉 As for /opt/tomcat7/logs/catalina.2021-09-02.log , that is a little bit better and in fact, you’ve prompted me to have a look at it. Thanks.

(I thought that I’d asked a very simple question. 😅 )

---

<div class="post-metadata">

**Author:** ![alwaysskint](https://talk.openmrs.org/letter_avatar/alwaysskint/32/6_449c533f586939b6e5f246632a46421f.png) [@alwaysskint](https://talk.openmrs.org/u/alwaysskint)\
**Post date:** [September 2, 2021, 3:22pm UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/4 "2021-09-02T15:22:44Z")

</div>

I’ve truncated the logs (and touched catalina.out, so that it repopulates):

> **[OpenMRS log error - Pastebin.com](https://pastebin.com/jMpcbXEM)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

---

<div class="post-metadata">

**Author:** ![alwaysskint](https://talk.openmrs.org/letter_avatar/alwaysskint/32/6_449c533f586939b6e5f246632a46421f.png) [@alwaysskint](https://talk.openmrs.org/u/alwaysskint)\
**Post date:** [September 3, 2021, 12:17am UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/5 "2021-09-03T00:17:25Z")

</div>

Brand new installation and this is still a problem. Debian 9, mySQL 5.6, Java 1.8, /opt/tomcat7

```auto
2021-09-03 01:07:54,862 localhost-startStop-1 ERROR Unable to create file openmrs.log java.io.IOException: Permission denied

```

Currently, I have manually created a /var/lib/OpenMRS and deployed Platform 2.11 - runtime.properties and relevant files have been written to /var/lib/OpenMRS

I have also tried creating /opt/tomcat7/.OpenMRS, /home/username/.OpenMRS and /root/.OpenMRS; none of these help the situation. I removed them again, so at least now the code uses the fallback position of /var/lib

An openmrs.log file is created in /var/lib/OpenMRS

There also appears to be a missing environment variable somewhere, as I’ve seen the following frequently:

```auto
OpenmrsUtil.getRuntimePropertiesFilePathName(2138) |2021-09-03T01:08:59,686| Unable to find a runtime properties file at /openmrs-runtime.properties

```

There’s no way that it should be looking in the / directory.

Surely someone has come across this before?

---

<div class="post-metadata">

**Author:** ![herbert24](https://talk.openmrs.org/user_avatar/talk.openmrs.org/herbert24/32/8178_2.png) [@herbert24](https://talk.openmrs.org/u/herbert24)\
**Post date:** [September 3, 2021, 7:24am UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/6 "2021-09-03T07:24:31Z")

</div>

> [@alwaysskint](#):
>
> mySQL 5.6, Java 1.8,

could you try with tomcat 8 for this combination!!

---

<div class="post-metadata">

**Author:** ![alwaysskint](https://talk.openmrs.org/letter_avatar/alwaysskint/32/6_449c533f586939b6e5f246632a46421f.png) [@alwaysskint](https://talk.openmrs.org/u/alwaysskint)\
**Post date:** [September 3, 2021, 9:26am UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/7 "2021-09-03T09:26:11Z")

</div>

Unfortunately, that doesn’t answer the query.

**I don’t have the luxury of time/energy to try every conceivable combination and just want to get a workable solution.**

The chosen software combination is purely derived from the information scattered around OpenMRS. Otherwise, I’d have stuck with the sensible thing and used the latest stable versions of all the required software.

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [September 3, 2021, 1:56pm UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/8 "2021-09-03T13:56:07Z")

</div>

> [@alwaysskint](#):
>
> There also appears to be a missing environment variable somewhere, as I’ve seen the following frequently:
> 
> ```auto
> OpenmrsUtil.getRuntimePropertiesFilePathName(2138) |2021-09-03T01:08:59,686| Unable to find a runtime properties file at /openmrs-runtime.properties
> 
> ```
> 
> There’s no way that it should be looking in the / directory.
> 
> Surely someone has come across this before?

Just ignore this one. It is just a log for the first attempts to look for the runtime properties file.

---

<div class="post-metadata">

**Author:** ![alwaysskint](https://talk.openmrs.org/letter_avatar/alwaysskint/32/6_449c533f586939b6e5f246632a46421f.png) [@alwaysskint](https://talk.openmrs.org/u/alwaysskint)\
**Post date:** [September 3, 2021, 2:50pm UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/9 "2021-09-03T14:50:48Z")

</div>

> [@dkayiwa](#):
>
> Just ignore this one. It is just a log for the first attempts to look for the runtime properties file.

Hopefully that slack/poor bit of coding is addressed in later releases. 😉 I shall re-iterate: **There’s no way that it should be looking in the / directory** under any circumstances. Is this added to the other classic error to ignore?

```auto
ERROR - BrokerService.checkSystemUsageLimits(1925) |2021-09-03T12:57:31,737| Temporary Store limit is 51200 mb, whilst the temporary data directory: /var/lib/OpenMRS/activemq-data/localhost/tmp_storage only has 1775 mb of usable space

```

Still no-one seems able/wanting to reply to my original simple question. I daren’t imagine what kind of systems that others have OpenMRS running in. 😑 Do people just ignore warnings/errors until something nasty rears its’ head?

To those already responding, thanks for the effort though I need an answer to a specific question in this thread. I have another thread about the general implementation issues.

---

<div class="post-metadata">

**Author:** ![alwaysskint](https://talk.openmrs.org/letter_avatar/alwaysskint/32/6_449c533f586939b6e5f246632a46421f.png) [@alwaysskint](https://talk.openmrs.org/u/alwaysskint)\
**Post date:** [September 3, 2021, 6:52pm UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/10 "2021-09-03T18:52:55Z")

</div>

I’ve managed to debug the problem…

/opt/tomcat7/webapps/openmrs/WEB-INF/classes/log4j2.xml The undeclared path in the following line is the root cause. I don’t know the syntax for the xml, but it should be prefixed by, for examples the webapp (openmrs) or CATALINA\_TMPDIR variable. For debugging purposes, I hard-coded a path; **this is not a solution**.

```auto
<RollingFile name="DEBUGGING_FILE_APPENDER" fileName="/var/lib/OpenMRS/openmrs.log" filePattern="openmrs.%i.log.gz" append="false">

```

---

<div class="post-metadata">

**Author:** ![ibacher](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ibacher/32/19751_2.png) [@ibacher](https://talk.openmrs.org/u/ibacher)\
**Post date:** [September 3, 2021, 7:28pm UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/11 "2021-09-03T19:28:48Z")

</div>

@alwaysskint Yes, you’re right. You’re in no way expected to touch that file since the default should be to put the relative to the OpenMRS Application Directory ([the logic is here](https://github.com/openmrs/openmrs-core/blob/3be9b50232172e711a68a44b848f014dea68e59a/api/src/main/java/org/openmrs/util/OpenmrsUtil.java#L1158)).

We determine the OpenMRS Application Directory in several different ways. By default it’s in `~/.OpenMRS` for whatever the user running OpenMRS. If that directory isn’t writable, it tries to fall-back to /var/lib/OpenMRS/. However, [as documented here](https://wiki.openmrs.org/display/docs/Application+Data+Directory) there are a few ways that you can control which directory is regarded as the OpenMRS Application Directory.

If you setup the environment variable `CATALINA_OPTS` for the user your Tomcat install runs under to `"-DOPENMRS_APPLICATION_DATA_DIRECTORY=/var/lib/OpenMRS"` (and assuming this directory is writable by the user your Tomcat install runs under, the log file should be in the same place.

> [@alwaysskint](#):
>
> I shall re-iterate: **There’s no way that it should be looking in the / directory** under any circumstances.

The way that that code would end up looking for `/openmrs-runtime.properties` is if Tomcat is running with the current working directory of `/`, which is even more worrying as it implies that your `CATALINA_HOME` is set to `/`. You probably should verify that `/opt/tomcat7/bin/setenv.sh` (if any) is set sanely.

---

<div class="post-metadata">

**Author:** ![alwaysskint](https://talk.openmrs.org/letter_avatar/alwaysskint/32/6_449c533f586939b6e5f246632a46421f.png) [@alwaysskint](https://talk.openmrs.org/u/alwaysskint)\
**Post date:** [September 3, 2021, 7:43pm UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/12 "2021-09-03T19:43:55Z")

</div>

Now you’re talking my language. 🙂

Thanks!

`"-DOPENMRS_APPLICATION_DATA_DIRECTORY=/var/lib/OpenMRS"` is the key and I’ll add to the systemd startup.

> [@ibacher](#):
>
> which is even more worrying as it implies that your `CATALINA_HOME` is set to `/` . You probably should verify that `/opt/tomcat7/bin/setenv.sh` (if any) is set sanely.

See snippets below…

```auto
..
[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Environment=CATALINA_PID=/opt/tomcat7/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat7
Environment=CATALINA_BASE=/opt/tomcat7
Environment='CATALINA_OPTS=-Xmx1536M -Xms512M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

ExecStart=/opt/tomcat7/bin/startup.sh
ExecStop=/opt/tomcat7/bin/shutdown.sh

User=tomcat
Group=tomcat
..

```

```auto
/opt/tomcat7/bin/setenv.sh
export CATALINA_PID="/opt/tomcat7/work/tomcat.pid"
export CATALINA_TMPDIR="/opt/tomcat7/temp"

```

I see a difference in TMP definition, I’ll make them the same, though one will take precedence.

The wiki wasn’t loading…

I captured the environment in catalina.sh which gives the following:

```auto
LANGUAGE=en_GB:en
USER=tomcat
HOME=/opt/tomcat7
CATALINA_HOME=/opt/tomcat7
CATALINA_PID=/opt/tomcat7/temp/tomcat.pid
LOGNAME=tomcat
JOURNAL_STREAM=8:218431
JDK_JAVA_OPTIONS= --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
CATALINA_TMPDIR=/opt/tomcat7/temp
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
INVOCATION_ID=xxxxxxxxxxxxxxxxxxxxxx
JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Djdk.tls.ephemeralDHKeySize=2048 -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
LANG=en_GB.UTF-8
SHELL=/bin/false
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
PWD=/
CATALINA_BASE=/opt/tomcat7
CATALINA_OPTS=-Xmx1536M -Xms512M -server -XX:+UseParallelGC -DOPENMRS_APPLICATION_DATA_DIRECTORY=/var/lib/OpenMRS

```

I notice that the working directory isn’t set to the expected CATALINA\_BASE nor HOME. Interesting.

---

<div class="post-metadata">

**Author:** ![alwaysskint](https://talk.openmrs.org/letter_avatar/alwaysskint/32/6_449c533f586939b6e5f246632a46421f.png) [@alwaysskint](https://talk.openmrs.org/u/alwaysskint)\
**Post date:** [September 3, 2021, 10:39pm UTC](https://talk.openmrs.org/t/location-of-openmrs-log/34562/13 "2021-09-03T22:39:49Z")

</div>

> [@alwaysskint](#):
>
> I notice that the working directory isn’t set to the expected CATALINA\_BASE nor HOME

If I explicitly set the working directory in /opt/tomcat7/bin/setenv.sh , then there’s a much cleaner startup. I’m sure that there’s a better way. 😕

```auto
export CATALINA_PID="/opt/tomcat7/temp/tomcat.pid"
export CATALINA_TMPDIR="/opt/tomcat7/temp"
export CATALINA_HOME="/opt/tomcat7"
cd /var/lib/OpenMRS

```
