How to check logs for running container on Heroku? - java

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.

Related

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).

java webapp println statements shows up on tomcat console but not in the log files

When I deploy my war file on a standalone tomcat server and start tomcat using startup.bat script, All my System.out.println show up on the tomcat console and since there is lot of information they quickly refresh and I cant read them.
I don't see those statements in any of the tomcat log files. Is there a way to have them printed in log files(when tomcat console is open as well)? Looks like all that information gets printed on tomcat and never goes to the log files.
System.out.println isn't a good idea. Your experience is correct: Those records are written to the console. That's not helpful if you don't have access to the server.
A better solution is to use log4j or its successor, slf4j.
I wonder if this could be a solution for you.

Simple jhipster app builds and runs, but no admin interface generated

I built a simple jhipster app to start a new Spring Application project from. I chose:
Java 7
Local Auth
Postgresql both for production and development
No HTTP sessions
No Websocket
Ehcache
Maven
Grunt
I created the relevant Schemas in Postgresql and started the app with mvn spring-boot:run in the terminal and I get a starting page for my application on localhost. Only the navigation is visible and none of the attached javascripts seems to be running or at least working properly. In the javascript log I get "ReferenceError: angular is not defined". None of the links take me anywhere.
Talking about logs, the startup says the app is using org.jboss.logging. I see no log files. Anyone knows where the logs are? I'm trying to read the source code for log settings, but I can't seem to find the proper settings.
There are no created tables in the database either.
I assume there is a setting I missed somewhere, but I don't have a clue yet. Hopefully I can find the logs soon and get one.
Any ideas how to diagnose this problem is most welcome. Thank you.

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

Logging Google App Engine application

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!

Categories