Logging Google App Engine application - java

I have made my GAE application using the development server, but now when I deploy it to GAE cloud, some features don't work (some elements are missing), but no exceptions are thrown.
Now I'd like to have some logging to my code so I could find out why these things are working in development environment, but not in GAE cloud, but I haven't found a way to log events like I can do with the development server in Eclipse.
So is it possible to log events like you can do in the Eclipse development server?

Google App Engine applications written in Java can write information to the log files using java.util.logging.Logger. Log data for an application can be viewed and analyzed using the Administration Console, or downloaded using appcfg.sh request_logs.
More info in the Logging documentation.

You will have to configure logging via java.util.logging.Logger and a logging.properties file in your classpath, preferably in your WEB-INF/classes/ directory. e.g. if you want all your logging to be at the INFO level, the contents of this file should be:
# Set the default logging level for all loggers to INFO
.level = INFO

The article that was marked as correct answer is a little bit outdated.
Today if you have to read your logs or want remotely debug your app you can use
Google Stackdriver Logging (web)
Google Stackdriver Error Reporting (web)
Google Stackdriver Debug (web)
gcloud command-line interface to Google Cloud (console, just type gcloud app logs tail to see latests log from your deployed app)
Java GAE applications still write information to the log files using java.util.logging.Logger.
Again, if you want more information about the Google App Engine Java logging read the documentation.

I assume you are asking for the Log console to see the error info and such. if yes then open your Google app engine launcher and click on your app and you can see a Logs button on the top next to Run and Stop.
Good luck!

Related

How to view application logs compute engine in google cloud

I am new to google cloud. I have a java application and I write logs in my compute engines storage itself.
That is I have a log folder inside my e2-small machine and I have log files in that folder.
I can ssh to my compute engine and view logs but want to explore how to use google cloud tools for same.
I have explored
https://cloud.google.com/logging/docs/view/logs-viewer-interface
https://cloud.google.com/appengine/docs/standard/nodejs/building-app/viewing-service-logs
and also few stackoverflow questions.
Right now is view audit events for my compute engine like (Removing user viraj and Updating keys for user viraj)
Please let me know if any more information is required or if I am missing in my cloud setup?
As mentioned by #YariPelona, there's a post with a similar question at the post: How to logging python script log into Google stackdriver logging running on a Google Cloud VM.
The tool that will help you is Cloud Logging, which will allow you to see your logs in a Log Explorer ans setup custom monitoring depending on your app/project needs by installing the Monitoring agent, which includes setup guides for such monitoring at several 3rd party apps.
Find the guide to install, configure and authorize the monitoring agent in This link:
Installing the agent on a single VM
Then you can go to this link to find out how to use Cloud Loggin and see your logg in the Log Explorer by enabling it on your VM instance or using Cloud Shell with gcloud commands:
Quickstart using Logging tools.
And last but not least, in the next link you will find the Guides to monitor third-party applications like Apache web server, MySql, Cassandra, Tomcat, etc (Plugin enablement), with the tools mentioned above:
Monitoring third-party applications

How to check logs for running container on Heroku?

I deployed a sample Java app like container on Heroku. I made heroku container:push <name> and heroku container:release <name> afterwards. Commands worked but I don't understand if the app itself is running since it should fire few times per day.
I tried to see general logs, got nothing. Where can I find container-related logs in Heroku?
UPDATE:
My logs are the following:
2019-12-18T21:21:20.002711+00:00 app[api]: Release v4 created by user
2019-12-18T21:21:20.002711+00:00 app[api]: Deployed worker
(c77c435c1355) by user
After this, no logs appeared.
If you use a logging framework (log4j, java Logging) you still need to initialise it to log to the stdout (Console), you should then be able to see your logs in the Heroku "View Logs" (or indeed with CLI heroku logs).
Are you using log4j? Add log4j.properties in the classpath of your apps.
You can also try the System.out.println to log into the stdout.
Hope it helps.
Beppe
As #Beppe C's answer mentions, I can use log4j or similar logging solutions.
There are a couple of possibilities for logging.
Use plugins in Heroku such as Papertrail that will scrape logs from Docker and post them into themselves. You can see, filter, search, and archive logs there.
Use external systems such as Sentry, AWS Cloudwatch, you name it. You will need to set up appenders and config to where to send logs. They will be sent from application. You will see only application-specific logs, not Heroku specific as in the 1st solution.
You have two main options, and sometimes it's just a good idea to use them both.

How to log custom application logs generated by Java/Spring Boot app in Azure Application Logs?

I have a Spring Boot application that uses log4j2 to create a log file into "D:/home/LogFiles/azurefileapp/" folder in Azure Web App. The application can write logs to this folder properly without any issues.
Now the issue I have is I want to share these logs with other developers who are not having access to the Azure Portal. I thought of providing them with below cmd that downloads these logs (using Service Principal).
az webapp log download --resource-group --name
With above cmd the logs get downloaded but the current log file to which the app is writing the logs won't get downloaded as it is currently under write lock and locked by a process.
I already tried switching from log4j2 to slf4j. But same happens. The latest log file will not get downloaded. Once I stop the web app, I can download the latest log file without any issues.
Is there any way by which any of the following can be done?
1. The latest log file too can be downloaded without stopping the web app using the same "az webapp log download" cmd?
2. Or else, is there a way by which I can directly write to the log files that Azure Web App generates by itself when we switch on Application Logging.
3. Is there a way I can write my custom logs to the Azure Storage Blob through Spring Boot?
For this kind of requirements, we have the following options.
Splunk with Spring Boot
ELK stack with Spring Boot
Zipkin with Spring Boot
Logstash with Spring Boot
There may be many more. In case of Pivotal Cloud Foundary, there is an option to use Loggregator, if there is similar in Azure, you can leverage.

Application-specific log files in Bluemix Liberty Buildpack

I am currently evaluating an app migration to Bluemix. It currently uses the log4j properties to write different type of errors in different Application specific Log files. What are the options in Bluemix for the same, since I understand writing to files is not supported? What if I need similar application behaviour with minimal config /code change?
Sample config :
<appender name="info-out"
class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="filelocn/apps/logs/MyAppOnline-Info.log"/>
You could actually write on files, but it is something that should be avoided because of the Cloud Foundry nature, as you can see here Considerations for Designing and Running an Application in the Cloud.
Usually to log in Bluemix Java applications you have to log to STDOUT and have loggregator drain the logs. You then can retrieve them using cf logs appName --recent.
Another option is to use the IBM Monitoring and Analytics service. This add-on service will collect and persist log entries written by your Java application to standard Liberty runtime logs such as messages.log or trace.log. The Add-On collects and persists log entries and allows you to search and plot results graphically. The Add-On combines log analysis with availability and performance monitoring of your application. See Monitoring and Analytics - Log Analysis tab.
As a third option you could use a third party tool (take a look here).
Unfortunately none of the above options allow to create different files. If you really need to keep that kind of separation you could think to implement a DB logging system using log4j DB appender. Take a look here for some useful pointers.
When looking at log drains, make sure you test the output. We're using java.util.logging with Kibana 4 and it does not handle multi-line or stacktraces well (or at all).

How can I access the http access logs in Cloudbees

I am using Cloudbees as my PAAS provider and wish to see the access logs as can be viewed in Tomcat. In my apps section I see a tab showing Application Logs and a tab for Access logs which shows nothing.
Is there a way I can turn on these logs?
This was a configuration problem, and has been fixed now

Categories