Using the YARN CLI to viewlogs for applications
Use the YARN CLI to view logs for running application. Configure the log aggregation to aggregate and write out logs for all containers belonging to a single Application grouped by NodeManagers to single log files at a configured location in the file system.
You can access container log
files using the YARN ResourceManager web UI, but more options are available when you use
the yarn logs
CLI command.
View all log files for an application
Use the following command format to view all logs for an
application:
yarn logs -applicationId <Application ID>
View a specific log type for an application
Use the following command format to view all logs of a particular type for an
application:
yarn logs -applicationId <Application ID> -log_files <log_file_type>
For example, to view only the
stderr
error
logs:yarn logs -applicationId <Application ID> -log_files stderr
The -logFiles
option also supports Java regular expressions, so the
following format would return all types of log files:
yarn logs -applicationId <Application ID> -log_files .*
View ApplicationMaster log files
Use the following command format to view all ApplicationMaster container log files for
an
application:
yarn logs -applicationId <Application ID> -am ALL
Use the following command format to view only the first ApplicationMaster container log
files:
yarn logs -applicationId <Application ID> -am 1
List container IDs
Use the following command format to list all container IDs for an application:
yarn logs -applicationId <Application ID> -show_application_log_info
View log files for one container
Once you have the container IDs, you can use the following command format to list the
log files for a particular
container:
yarn logs -applicationId <Application ID> -containerId <Container ID>
Show container log file information
Use the following command format to list all of the container log file names (types) for
an
application:
yarn logs -applicationId <Application ID> -show_container_log_info
You
can then use the -logFiles
option to view a particular log type.View a portion of the log files for one container
For large container log files, you can use the following command format to list only a
portion of the log files for a particular
container:
yarn logs -applicationId <Application ID> -containerId <Container ID> -size <bytes>
To view the first 1000
bytes:
yarn logs -applicationId <Application ID> -containerId <Container ID> -size 1000
To view the last 1000
bytes:
yarn logs -applicationId <Application ID> -containerId <Container ID> -size -1000
Download logs for an application
Use the following command format to download logs to a local
folder:
yarn logs -applicationId <Application ID> -out <path_to_local_folder>
The container log files are organized in parent folders labeled with the applicable node ID.
Display help for YARN logs
To display Help for
yarn logs
, run the following
command:yarn logs -help