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).
Related
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
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.
I have tried several logging frameworks (log4j / slf4j with logback/ commons-logging) on websphere to redirect each application log on a separate file, without any sucess.
If i have two applications deployed on same JVM: I am not able to know related errors of each application: All non catched exceptions gets redirected to SystemOut.log file, instead of getting redirected to the appropriate application log file.
Is there any way to achieve that on websphere ?
It would be useful if you post the configuration files you've tried for each logging framework, and provide more details of each scenario. I have used log4j and logback with WebSphere and never ran into problems like yours.
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!
I've got some MBean operations that I need to secure. I would like the users to be required to log in as the server admin and I would like this to be setup programmaticly or, preferably by a config file in the WAR, when the app is deployed. I want to avoid requiring the admin to set this up as a deployment step.
We're running glassfish, but platform neutral is preferred. However, glassfish specific config files would be fine.
By default, the Sun JDK allows you to perform access control by putting credentials in the filesystem, which would live outside your jar. See the management guide for details.
However, since you want to control things from within your app, you can use JAAS to replace the file-based configuration with your own. See the java docs on com.sun.jmx.remote.security.JMXPluggableAuthenticator for details.
You could programmatically inject your own JAAS provider, and then manage the authentication details however you like.