How to print log in flink-streaming-java module

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to print log in flink-streaming-java module

Polarisary
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





Reply | Threaded
Open this post in threaded view
|

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

sysuke Lee
Pls refer to conf/log4j.properties

Polarisary <[hidden email]> 于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





Reply | Threaded
Open this post in threaded view
|

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

Leonard Xu
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



在 2020年4月21日,12:06,Lee Sysuke <[hidden email]> 写道:

Pls refer to conf/log4j.properties

Polarisary <[hidden email]> 于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