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.
Related
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 am using third party framework and our application and that framework both are having same logger slf4j. I have deployed my application on Tomcat and IBM WAS. Now I am seeing few severe exceptions from that framework, which I want to hide, and only want to see the logs of my application. Please suggest, how we could achieve it.
We have ported an EJB application from BEA Weblogic 8.1 to Glassfish 2.1.
The client is accessing the server through RMI, no web client.
In Weblogic exceptions were logged automatically to server.log, even when they are catched and rethrown to the client.
In Glassfish with default configuration we can't see them in server.log.
How can I get the same behavior as with Weblogic?
Glassfish 2.1 logs via java.util.logging. Logging content, by default, is collected in
[Glassfish root]/domains/[domain name]/logs/server.log
For configuring j.u.l, find the logging.properties file in the JRE that is used to run Glassfish (in the lib directory), set your topics' (loggers') levels to desired granularity.
Note: that worked for me for an application using Apache Commons Logging, running on Glassfish.
My Java EE application, which currently runs on Glassfish 3, is currently using java.util.logging to send logmessages. This is intercepted by Glassfish and written to files.
I'd like to switch to a centralised logging solution, since the application is going to be distributed in a cluster.
I have an existing syslog infrastructure. Do you have any suggestion, how to get the application to log to syslog? Glassfish's log-to-syslog feature has no documentation and no configuration, so I haven't considered it much.
What about migrating to SLF4J and using the SLF4J syslog appender?
Please have a look a look at Glassfish to Syslog which shows how to let GlassFish 3 log to system log/syslog via UDP 514 on localhost.
I have a quite ordinary web application which logs with slf4j, which is fine, and I have used several slf4j backends without any problems.
Under Tomcat I just told logback to point at a location in the filesystem and log there, but now I want to deploy several independent instances of this application each in its own domain in a single Glassfish 3.0.1 instance, and I have now found that I would like my slf4j logging to work well with Glassfish.
What would be a good way (dare I say "best") to have my logging taken care of by Glassfish. Should I just flatten my logs to System.out with logback and let Glassfish handle the console output, or is there a better, standard way to reach the loggers inside Glassfish?
EDIT: Investigation has shown that GlassFish 3.0.1 does not provide neither the SLF4J API or a binding in the classes visible to a JSP-page with default configuration.
By providing slf4j-api-X.jar and slf4j-jdk14-X.jar the slf4j-logging events are forwarded to java.util.logging which is captured properly by Glassfish (see http://docs.sun.com/app/docs/doc/820-7692/abluj?l=en&a=view for details).
Investigation has shown that GlassFish 3.0.1 does not provide neither the SLF4J API or a binding in the classes visible to a JSP-page with default configuration.
By providing slf4j-api-X.jar and slf4j-jdk14-X.jar the slf4j-logging events are forwarded to java.util.logging which is captured properly by Glassfish (see http://docs.sun.com/app/docs/doc/820-7692/abluj?l=en&a=view for details).
Note: Glassfish logging does not capture stack traces.