You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Polarisary <po...@gmail.com> on 2020/04/21 03:07:50 UTC

How to print log in flink-streaming-java module

Hi all, 
when i add some log in org.apache.flink.streaming.api.environment( flink-streaming-java module ) and package flink-dist_2.11-1.10.0.jar, but it print nothing in jm or tm log.

i did it like this:

	```
public JobClient executeAsync(StreamGraph streamGraph) throws Exception {
   checkNotNull(streamGraph, "StreamGraph cannot be null.");
   checkNotNull(configuration.get(DeploymentOptions.TARGET), "No execution.target specified in your configuration file.");

   final PipelineExecutorFactory executorFactory =
      executorServiceLoader.getExecutorFactory(configuration);

   checkNotNull(
      executorFactory,
      "Cannot find compatible factory for specified execution.target (=%s)",
      configuration.get(DeploymentOptions.TARGET));

   LOG.error("# Note >>> DeploymentOptions.TARGET : {}", DeploymentOptions.TARGET);
```

Do someone know how to add log in this java class
												
							Waiting for reply, Many Thanks






Re: How to print log in flink-streaming-java module

Posted by Leonard Xu <xb...@gmail.com>.
Hi, Lee

Flink ships with the following default properties files[1]:

log4j-cli.properties: Used by the Flink command line client (e.g. flink run) (not code executed on the cluster)
log4j-yarn-session.properties: Used by the Flink command line client when starting a YARN session (yarn-session.sh)
log4j.properties: JobManager/Taskmanager logs (both standalone and YARN)
If you want to print log to jm/tm log please use
 `import org.slf4j.Logger;
import org.slf4j.LoggerFactory;` to create `LOG`
 and config log4j.properties according your requirements(log level, log path…)

Best,
Leonard Xu

[1]https://ci.apache.org/projects/flink/flink-docs-master/monitoring/logging.html <https://ci.apache.org/projects/flink/flink-docs-master/monitoring/logging.html>


> 在 2020年4月21日,12:06,Lee Sysuke <sy...@gmail.com> 写道:
> 
> Pls refer to conf/log4j.properties
> 
> Polarisary <polarisary@gmail.com <ma...@gmail.com>> 于2020年4月21日周二 上午11:08写道:
> Hi all, 
> when i add some log in org.apache.flink.streaming.api.environment( flink-streaming-java module ) and package flink-dist_2.11-1.10.0.jar, but it print nothing in jm or tm log.
> 
> i did it like this:
> 
> 	```
> public JobClient executeAsync(StreamGraph streamGraph) throws Exception {
>    checkNotNull(streamGraph, "StreamGraph cannot be null.");
>    checkNotNull(configuration.get(DeploymentOptions.TARGET), "No execution.target specified in your configuration file.");
> 
>    final PipelineExecutorFactory executorFactory =
>       executorServiceLoader.getExecutorFactory(configuration);
> 
>    checkNotNull(
>       executorFactory,
>       "Cannot find compatible factory for specified execution.target (=%s)",
>       configuration.get(DeploymentOptions.TARGET));
> 
>    LOG.error("# Note >>> DeploymentOptions.TARGET : {}", DeploymentOptions.TARGET);
> ```
> 
> Do someone know how to add log in this java class
> 												
> 							Waiting for reply, Many Thanks
> 
> 
> 
> 
> 


Re: How to print log in flink-streaming-java module

Posted by Lee Sysuke <sy...@gmail.com>.
Pls refer to conf/log4j.properties

Polarisary <po...@gmail.com> 于2020年4月21日周二 上午11:08写道:

> Hi all,
> when i add some log in org.apache.flink.streaming.api.environment(
> flink-streaming-java module ) and package flink-dist_2.11-1.10.0.jar, but
> it print nothing in jm or tm log.
>
> i did it like this:
>
> ```
> public JobClient executeAsync(StreamGraph streamGraph) throws Exception {
> checkNotNull(streamGraph, "StreamGraph cannot be null.");
> checkNotNull(configuration.get(DeploymentOptions.TARGET), "No
> execution.target specified in your configuration file.");
>
> final PipelineExecutorFactory executorFactory =
> executorServiceLoader.getExecutorFactory(configuration);
>
> checkNotNull(
> executorFactory,
> "Cannot find compatible factory for specified execution.target (=%s)",
> configuration.get(DeploymentOptions.TARGET));
>
> LOG.error("# Note >>> DeploymentOptions.TARGET : {}", DeploymentOptions.
> TARGET);
> ```
>
> Do someone know how to add log in this java class
> Waiting for reply, Many Thanks
>
>
>
>
>
>