本地运行Scala项目输出正常,提交至Azure Spark集群后无输出咨询
Hey there! Let's tackle your questions one by one:
First off, you're totally right—Scala's println does rely on Java's System.out.println under the hood, so your initial understanding is spot-on.
Now, about missing the "Test" output when running your Jar on Azure Spark clusters: here's where you can find those logs, plus fixes if you can't see them:
Where to Find Your Spark Job Output on Azure
1. Azure Portal (Most Reliable Option)
- Log into the Azure Portal and navigate to your Spark cluster (this could be an Azure HDInsight cluster or a Spark pool in Azure Synapse Analytics)
- Head to the Job Management or Spark Applications section, then locate the job you submitted via IntelliJ's Azure Toolkit
- Open the job details page, then look for the Logs tab. Your
printlnoutput will almost always show up in the Driver Logs—sinceSystem.outoutput is captured and routed to the driver's log stream by default- For Azure Synapse specifically: Go to Monitor > Spark applications, select your job, then check the
stdoutandstderrlogs under the Logs section
- For Azure Synapse specifically: Go to Monitor > Spark applications, select your job, then check the
2. Directly via Azure Toolkit for IntelliJ
- After submitting your job, in the bottom Azure Toolkit window, find your Spark job entry
- Right-click it and select View Logs or View Application Details—this will either load logs directly in the IDE or take you to the corresponding Azure Portal log page
- Note: Real-time log streaming might have a slight delay, so give it a minute or two if you don't see output immediately
If You Still Can't See the Output
Try these adjustments to ensure your output gets captured:
- Use Spark's Logging API Instead of
println:printlncan sometimes get lost or not prioritized in cluster log systems. Switching to Spark's recommended logging frameworks (like SLF4J) ensures your output is properly integrated with Spark's log pipeline:import org.slf4j.LoggerFactory class YourScalaClass { private val logger = LoggerFactory.getLogger(getClass) logger.info("Test") // This will show up in cluster logs consistently } - Verify Job Execution:
Double-check that your job actually ran successfully and reached the output line. In the job details page, check the Status and Execution Steps to confirm the code path with your output was executed. - Adjust Log Levels:
If your output is being filtered out, you can adjust the log level when submitting the job. Add a configuration parameter like:
This ensures INFO-level logs (including your custom messages) are captured.--conf spark.driver.extraJavaOptions="-Dlog4j.rootLogger=INFO,console" - Check Cloud Storage for Logs:
Cloud-hosted Spark clusters often persist logs to Azure Blob Storage. For example, HDInsight stores logs in a Blob container under the/cluster-logspath. You can access this storage via the Azure Portal to dig deeper if needed.
内容的提问来源于stack exchange,提问作者JetS79
相关产品推荐
相关产品推荐

