<commit_before>---
title: Troubleshoot Application Deployment and Health
---

_This page assumes that you are using cf v6._

## <a id='cf-commands'></a>cf Troubleshooting Commands ##

Cloud Foundry's cf command line interface provides several commands you can use
to investigate application deployment and health.

* `cf apps`: Returns a list of the applications deployed to the current space
with deployment options, including the name, current state, number of instances,
memory and disk allocations, and URLs of each application.

* `cf app APP_NAME`: Returns the health and status of each instance of a
specific application in the current space, including instance ID number, current
state, how long it has been running, and how much CPU, memory, and disk it is
using.

* `cf env APP_NAME`: Returns environment variables set using `cf set-env`.

* `cf logs APP_NAME`: Returns a real-time stream of the application STDOUT and
STDERR. Use **Ctrl-C** (^C) to exit the real-time stream.

* `cf events APP_NAME`: Returns information about application crashes, including
error codes.
See
[https://github.com/cloudfoundry/errors](https://github.com/cloudfoundry/errors)
for a list of Cloud Foundry errors.

* `cf files APP_NAME`: Returns a list of files in an application directory.

Your application should direct its logs to STDOUT and STDERR.
The `logs` command also returns messages from any [log4j](http://logging.apache.org/log4j/)
facility that you configure to send logs to STDOUT.

**Note:** Some of these commands may return connection credentials, so be sure
not to post command output to a public forum without first removing this
sensitive information.


## <a id='java-apps'></a>Java and Grails Best Practices ##

### <a id='jdbc'></a>Provide JDBC driver ###

The Java buildpack does not bundle a JDBC driver with your application.
If your application will access a SQL RDBMS, include the appropriate driver in
your application.

### <a id='memory'></a>Allocate Sufficient Memory ###

If you do not allocate sufficient memory to a Java application when you deploy
it, it may fail to start, or be killed by Cloud Foundry.
Allocate enough memory to allow for Java heap, PermGen, thread stacks, and JVM
overhead.
The Java buildpack allocates 10% of the memory limit to PermGen.
Memory-related JVM options are configured in `config/openjdk.yml`
(https://github.com/cloudfoundry/java-buildpack/blob/master/config/openjdk.yml).
When your application is running, you can use the `cf app APP_NAME` command to
see memory utilization.
<commit_msg>remove most references to cf files command<commit_after>---
title: Troubleshoot Application Deployment and Health
---

_This page assumes that you are using cf v6._

## <a id='cf-commands'></a>cf Troubleshooting Commands ##

Cloud Foundry's cf command line interface provides several commands you can use
to investigate application deployment and health.

* `cf apps`: Returns a list of the applications deployed to the current space
with deployment options, including the name, current state, number of instances,
memory and disk allocations, and URLs of each application.

* `cf app APP_NAME`: Returns the health and status of each instance of a
specific application in the current space, including instance ID number, current
state, how long it has been running, and how much CPU, memory, and disk it is
using.

* `cf env APP_NAME`: Returns environment variables set using `cf set-env`.

* `cf logs APP_NAME`: Returns a real-time stream of the application STDOUT and
STDERR. Use **Ctrl-C** (^C) to exit the real-time stream.

* `cf events APP_NAME`: Returns information about application crashes, including
error codes.
See
[https://github.com/cloudfoundry/errors](https://github.com/cloudfoundry/errors)
for a list of Cloud Foundry errors.

* `cf files APP_NAME`: Returns a list of files in an application directory.

Your application should direct its logs to STDOUT and STDERR.
The `logs` command also returns messages from any [log4j](http://logging.apache.org/log4j/)
facility that you configure to send logs to STDOUT.

**Note:** Some of these commands may return connection credentials.
Take care to remove credentials and other sensitive information from command
output before you post the output a public forum.

For more about `cf logs`, see [Viewing Logs in the Command Line Interface](./deploy-apps/streaming-logs.html#view).

## <a id='java-apps'></a>Java and Grails Best Practices ##

### <a id='jdbc'></a>Provide JDBC driver ###

The Java buildpack does not bundle a JDBC driver with your application.
If your application will access a SQL RDBMS, include the appropriate driver in
your application.

### <a id='memory'></a>Allocate Sufficient Memory ###

If you do not allocate sufficient memory to a Java application when you deploy
it, it may fail to start, or be killed by Cloud Foundry.
Allocate enough memory to allow for Java heap, PermGen, thread stacks, and JVM
overhead.
The Java buildpack allocates 10% of the memory limit to PermGen.
Memory-related JVM options are configured in `config/openjdk.yml`
(https://github.com/cloudfoundry/java-buildpack/blob/master/config/openjdk.yml).
When your application is running, you can use the `cf app APP_NAME` command to
see memory utilization.

{'fraction_non_alphanumeric': 0.07812203003231324, 'fraction_numerical': 0.0019007793195210036, 'mean_word_length': 4.719565217391304, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5618239', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1393, 'n_words': 715}