Can I view the logging output by preview / debugger in Foundry? - foundry-code-repositories

Using Foundry authoring, is it possible to see the logs output by my code when using the Preview or Debugger? In particular logs output by log4j or Python logger.

Logger utilities do not output into the preview agent.
You can technically output to the debugger, but it does require to understand what handler is used there.

Related

Google Cloud Logging assigns ERROR severity to all Python logging.info calls

It's the first time I use Google Cloud Platform, so please be understanding!
I've built a scheduled workflow that simply runs a Batch job. The job runs Python code and uses the standard logging library for logging. When the job is executed, I can correctly see all the entries in Cloud Logging, but all the entries have severity ERROR although they're all INFO.
One possible reason I've been thinking about is that I haven't used the setup_logging function as described in the documentation here. The thing is, I didn't want to run the Cloud Logging setup when I run the code locally.
The questions I have are:
why does logging "work" (in the sense that logs end up in Cloud Logging) even if I did not use the setup_logging function? What is it's real role?
why do my INFO entries show up with ERROR severity?
if I include that snippet and that snippet solves this issue, should I include an if statement in my code that detects if I am running the code locally and skips that Cloud Logging setup step?
According to the documentation, you have to use a setup to send correctly logs to Cloud Logging.
This setup allows then to use the Python logging standard library.
Once installed, this library includes logging handlers to connect
Python's standard logging module to Logging, as well as an API client
library to access Cloud Logging manually.
# Imports the Cloud Logging client library
import google.cloud.logging
# Instantiates a client
client = google.cloud.logging.Client()
# Retrieves a Cloud Logging handler based on the environment
# you're running in and integrates the handler with the
# Python logging module. By default this captures all logs
# at INFO level and higher
client.setup_logging()
Then you can use the Python standard library to add logs to Cloud Logging.
# Imports Python standard library logging
import logging
# The data to log
text = "Hello, world!"
# Emits the data using the standard logging module
logging.warning(text)
why does logging "work" (in the sense that logs end up in Cloud Logging) even if I did not use the setup_logging function? What is
it's real role?
Without the setup, the log will be added to Cloud Logging but not with the correct type and as expected. It's better to use the setup.
why do my INFO entries show up with ERROR severity?
The same reason explained above
if I include that snippet and that snippet solves this issue, should I include an if statement in my code that detects if I am running the
code locally and skips that Cloud Logging setup step?
I think no need to add a if statement you run the code locally. In this case, the logs should be printed in the console even if the setup is present.

Logging jobs on a Google Cloud VM

I am using a Google Cloud virtual machine to run several python scripts scheduled on a cron, I am looking for some way to check that they ran.
When I look in my logs I see nothing, so I guess simply running a .py file is not logged? Is there a way to turn on logging at this level? What are the usual approaches for such things?
The technology for recording log information in GCP is called Stackdriver. You have a couple of choices for how to log within your application. The first is to instrument your code with Stackdriver APIs which explicitly write data to the Stackdriver subsytem. Here are the docs for that and here is further recipe.
A second story is that you install the Stackdriver Logging Agent on your Compute Engine. This will then allow you to tap into other sources of logging output such as local syslog.

Google Stackdriver Error Reporting blank (not set up)

We are starting to enable Stackdriver for our project, but while I have a ubuntu instance with stackdriver logging, and I am getting the logs shipped back (I can see the logs in Stackdriver Logging), when I browse to Error Reporting, it's just a blank screen with a button to "Setup Error Reporting", which takes me to some API documentation which I think is tailored for new application coding. We are running nginx and the logging is working, but I can't for the life of me figure out how to get the Error Reporting to work properly, if that's even doable.
"Setup Error Reporting" should guide you to the setup documentation (not API documentation). Depending on the platform you are using, you might need to perform some changes in your application's code or log format. Read more at https://cloud.google.com/error-reporting/docs/setup/
If you have Stackdriver Logging setup and on Google Compute Engine, the requirement is for your exception stack traces to be log in single log entries.

Where can I find request and response logs for Spark?

I have just started using Spark framework. And experimenting with a local server on Mac OS
The documentation says that to enable debug logs I simply need to add a dependency.
I've added a dependency and can observe logs in the console.
The question is where the log files are located?
If you are following the Spark example here, you are only enabling slf4j-simple logging. By default, this only logs items to the console. You can change this programmatically (Class information here) or by adding a properties file to the classpath, as seen in this discussion. Beyond this you will likely want to implement a logging framework like log4j or logback, as slf4j is designed to act as a facade over an existing logging implementation.

Can I catch VSTS Agent output with SDK?

I'm trying to write simple CLI tool, helping me with several VSTS-related tasks, like:
Create project from template
Building and watching build from console
etc
So, it would be nice to attach to running build (triggered via CI) and watch console output in live in my desktop console. Is there such ability in SDK?
I'm currently using this packages:
https://www.visualstudio.com/en-us/docs/integrate/get-started/client-libraries/dotnet
There isn't any API can achieve this feature as I know. You can submit a feature request on VSTS User Voice.